diff --git a/lbry/conf.py b/lbry/conf.py index 96b4b4389..5edbd4108 100644 --- a/lbry/conf.py +++ b/lbry/conf.py @@ -628,6 +628,7 @@ class Config(CLIConfig): # protocol timeouts download_timeout = Float("Cumulative timeout for a stream to begin downloading before giving up", 30.0) blob_download_timeout = Float("Timeout to download a blob from a peer", 30.0) + hub_timeout = Float("Timeout when making a hub request", 30.0) peer_connect_timeout = Float("Timeout to establish a TCP connection to a peer", 3.0) node_rpc_timeout = Float("Timeout when making a DHT request", constants.RPC_TIMEOUT) diff --git a/lbry/wallet/__init__.pyc b/lbry/wallet/__init__.pyc new file mode 100644 index 000000000..d4854844f Binary files /dev/null and b/lbry/wallet/__init__.pyc differ diff --git a/lbry/wallet/manager.py b/lbry/wallet/manager.py index 3dd99f227..1904f303a 100644 --- a/lbry/wallet/manager.py +++ b/lbry/wallet/manager.py @@ -183,6 +183,7 @@ class WalletManager: ledger_config = { 'auto_connect': True, 'explicit_servers': [], + 'hub_timeout': config.hub_timeout, 'default_servers': config.lbryum_servers, 'known_hubs': config.known_hubs, 'jurisdiction': config.jurisdiction, @@ -236,6 +237,7 @@ class WalletManager: 'default_servers': Config.lbryum_servers.default, 'known_hubs': self.config.known_hubs, 'jurisdiction': self.config.jurisdiction, + 'hub_timeout': self.config.hub_timeout, 'data_path': self.config.wallet_dir, } if Config.lbryum_servers.is_set(self.config): diff --git a/lbry/wallet/network.py b/lbry/wallet/network.py index 7367a87e3..955cbcb22 100644 --- a/lbry/wallet/network.py +++ b/lbry/wallet/network.py @@ -294,6 +294,7 @@ class Network: (pong.country_name != self.jurisdiction): continue client = ClientSession(network=self, server=(host, port)) + client = ClientSession(network=self, server=(host, port), timeout=self.config['hub_timeout']) try: await client.create_connection() log.warning("Connected to spv server %s:%i", host, port) diff --git a/lbry/wallet/orchstr8/node.py b/lbry/wallet/orchstr8/node.py index ed634628c..9ae8cfc8d 100644 --- a/lbry/wallet/orchstr8/node.py +++ b/lbry/wallet/orchstr8/node.py @@ -136,6 +136,7 @@ class WalletNode: 'default_servers': Config.lbryum_servers.default, 'data_path': self.data_path, 'known_hubs': config.known_hubs if config else KnownHubsList() + 'hub_timeout': 30, } }, 'wallets': [wallet_file_name] diff --git a/tests/integration/blockchain/test_network.py b/tests/integration/blockchain/test_network.py index 3f6e9e2d0..886c234a7 100644 --- a/tests/integration/blockchain/test_network.py +++ b/tests/integration/blockchain/test_network.py @@ -9,6 +9,7 @@ from lbry.wallet.orchstr8.node import SPVNode from lbry.wallet.rpc import RPCSession from lbry.wallet.server.udp import StatusServer from lbry.testcase import IntegrationTestCase, AsyncioTestCase +from lbry.conf import Config class NetworkTests(IntegrationTestCase): @@ -138,6 +139,15 @@ class ReconnectTests(IntegrationTestCase): await self.ledger.network.on_connected.first self.assertTrue(self.ledger.network.is_connected) + async def test_timeout_propagated_from_config(self): + conf = Config() + self.assertEqual(self.ledger.network.client.timeout, 30) + conf.hub_timeout = 123.0 + conf.lbryum_servers = self.ledger.config['default_servers'] + self.manager.config = conf + await self.manager.reset() + self.assertEqual(self.ledger.network.client.timeout, 123) + # async def test_online_but_still_unavailable(self): # # Edge case. See issue #2445 for context # self.assertIsNotNone(self.ledger.network.session_pool.fastest_session)