`ib`: drop use of `_account2clients` in `load_clients_for_trio()`
Instead adjust `load_aio_clients()` to only reload clients detected as non-loaded or disconnected (2 birds), and avoid use of the global module table which could result in stale disconnected clients persisting on multiple `brokerd` client reconnects, resulting in error.rekt_pps
parent
16e11d447c
commit
f3049016d6
|
@ -387,8 +387,7 @@ class Client:
|
||||||
bar_size, duration, dt_duration = _samplings[sample_period_s]
|
bar_size, duration, dt_duration = _samplings[sample_period_s]
|
||||||
|
|
||||||
global _enters
|
global _enters
|
||||||
# log.info(f'REQUESTING BARS {_enters} @ end={end_dt}')
|
log.info(
|
||||||
print(
|
|
||||||
f"REQUESTING {duration}'s worth {bar_size} BARS\n"
|
f"REQUESTING {duration}'s worth {bar_size} BARS\n"
|
||||||
f'{_enters} @ end={end_dt}"'
|
f'{_enters} @ end={end_dt}"'
|
||||||
)
|
)
|
||||||
|
@ -730,7 +729,7 @@ class Client:
|
||||||
)
|
)
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
exch in ('IDEALPRO')
|
exch in {'IDEALPRO'}
|
||||||
or sectype == 'CASH'
|
or sectype == 'CASH'
|
||||||
):
|
):
|
||||||
# if '/' in symbol:
|
# if '/' in symbol:
|
||||||
|
@ -1199,9 +1198,14 @@ async def load_aio_clients(
|
||||||
for host, port in combos:
|
for host, port in combos:
|
||||||
|
|
||||||
sockaddr = (host, port)
|
sockaddr = (host, port)
|
||||||
|
|
||||||
|
maybe_client = _client_cache.get(sockaddr)
|
||||||
if (
|
if (
|
||||||
sockaddr in _client_cache
|
sockaddr in _scan_ignore
|
||||||
or sockaddr in _scan_ignore
|
or (
|
||||||
|
maybe_client
|
||||||
|
and maybe_client.ib.isConnected()
|
||||||
|
)
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -1307,14 +1311,8 @@ async def load_clients_for_trio(
|
||||||
a ``tractor.to_asyncio.open_channel_from()``.
|
a ``tractor.to_asyncio.open_channel_from()``.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
global _accounts2clients
|
|
||||||
|
|
||||||
if _accounts2clients:
|
|
||||||
to_trio.send_nowait(_accounts2clients)
|
|
||||||
await asyncio.sleep(float('inf'))
|
|
||||||
|
|
||||||
else:
|
|
||||||
async with load_aio_clients() as accts2clients:
|
async with load_aio_clients() as accts2clients:
|
||||||
|
|
||||||
to_trio.send_nowait(accts2clients)
|
to_trio.send_nowait(accts2clients)
|
||||||
|
|
||||||
# TODO: maybe a sync event to wait on instead?
|
# TODO: maybe a sync event to wait on instead?
|
||||||
|
@ -1517,7 +1515,8 @@ async def open_client_proxy(
|
||||||
|
|
||||||
# mock all remote methods on ib ``Client``.
|
# mock all remote methods on ib ``Client``.
|
||||||
for name, method in inspect.getmembers(
|
for name, method in inspect.getmembers(
|
||||||
Client, predicate=inspect.isfunction
|
Client,
|
||||||
|
predicate=inspect.isfunction,
|
||||||
):
|
):
|
||||||
if '_' == name[0]:
|
if '_' == name[0]:
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue