forked from LBRYCommunity/lbry-sdk
add hub_timeout and propagate it to network code
This commit is contained in:
parent
fea893d76c
commit
91323a21cf
6 changed files with 15 additions and 0 deletions
|
@ -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)
|
||||
|
||||
|
|
BIN
lbry/wallet/__init__.pyc
Normal file
BIN
lbry/wallet/__init__.pyc
Normal file
Binary file not shown.
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue