From de9f215c832859a286c68f9a0566e5393e07fb3e Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 22 Aug 2022 17:52:47 -0400 Subject: [PATCH] If more then one `ib` api client is available use next available for search --- piker/brokers/ib/feed.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 85634c18..18981f60 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -867,17 +867,24 @@ async def open_symbol_search( # TODO: load user defined symbol set locally for fast search? await ctx.started({}) - # async with open_data_client() as proxy: async with ( open_client_proxies() as (proxies, clients), + open_data_client() as data_proxy, ): async with ctx.open_stream() as stream: - # await tractor.breakpoint() - proxy = proxies['ib.algopaper'] + # select a non-history client for symbol search to lighten + # the load in the main data node. + proxy = data_proxy + for name, proxy in proxies.items(): + if proxy is data_proxy: + continue + break + + ib_client = proxy._aio_ns.ib + log.info(f'Using {ib_client} for symbol search') last = time.time() - async for pattern in stream: log.info(f'received {pattern}') now = time.time() @@ -938,7 +945,9 @@ async def open_symbol_search( await trio.sleep(0) if cs.cancelled_caught: - log.warning(f'Search timeout? {proxy._aio_ns.ib.client}') + log.warning( + f'Search timeout? {proxy._aio_ns.ib.client}' + ) continue else: break