Increases IB api connect timeout to 1s

misc_ib_updates
Tyler Goodlet 2021-12-20 14:16:38 -05:00
parent fc3baf4bd1
commit 746db60e5b
1 changed files with 8 additions and 2 deletions

View File

@ -739,11 +739,13 @@ async def load_aio_clients(
client_id: Optional[int] = None, client_id: Optional[int] = None,
) -> Client: ) -> Client:
'''Return an ``ib_insync.IB`` instance wrapped in our client API. '''
Return an ``ib_insync.IB`` instance wrapped in our client API.
Client instances are cached for later use. Client instances are cached for later use.
TODO: consider doing this with a ctx mngr eventually? TODO: consider doing this with a ctx mngr eventually?
''' '''
global _accounts2clients, _client_cache, _scan_ignore global _accounts2clients, _client_cache, _scan_ignore
@ -782,7 +784,7 @@ async def load_aio_clients(
try_ports = list(ports.values()) try_ports = list(ports.values())
ports = try_ports if port is None else [port] ports = try_ports if port is None else [port]
# we_connected = [] # we_connected = []
connect_timeout = 0.5 if platform.system() != 'Windows' else 1 connect_timeout = 1 if platform.system() != 'Windows' else 2
combos = list(itertools.product(hosts, ports)) combos = list(itertools.product(hosts, ports))
# allocate new and/or reload disconnected but cached clients # allocate new and/or reload disconnected but cached clients
@ -1300,6 +1302,10 @@ async def _setup_quote_stream(
# resulting in tracebacks spammed to console.. # resulting in tracebacks spammed to console..
# Manually do the dereg ourselves. # Manually do the dereg ourselves.
teardown() teardown()
except trio.WouldBlock:
log.warning(f'channel is blocking symbol feed for {symbol}?'
f'\n{to_trio.statistics}'
)
# except trio.WouldBlock: # except trio.WouldBlock:
# # for slow debugging purposes to avoid clobbering prompt # # for slow debugging purposes to avoid clobbering prompt