From 0068119a6d3d3c3272f3230057e547547db13f32 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Wed, 16 Aug 2023 16:57:11 -0400 Subject: [PATCH] ib: use `asyncio.wait_for()` on ticker first quote; on 3.11 input coros are not allowed.. --- piker/brokers/ib/_util.py | 21 +++++++++++++++------ piker/brokers/ib/api.py | 12 +++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/piker/brokers/ib/_util.py b/piker/brokers/ib/_util.py index 05417d98..a80bd514 100644 --- a/piker/brokers/ib/_util.py +++ b/piker/brokers/ib/_util.py @@ -88,16 +88,25 @@ async def data_reset_hack( api_port: str = str(ib_client.client.port) vnc_host: str vnc_port: int - vnc_host, vnc_port = client.conf['vnc_addrs'].get( - api_port, - ('localhost', 3003) - ) + vnc_sockaddr: tuple[str] | None = client.conf.get('vnc_addrs') no_setup_msg:str = ( - f'No data reset hack test setup for {vnc_host}!\n' - 'See setup @\n' + f'No data reset hack test setup for {vnc_sockaddr}!\n' + 'See config setup tips @\n' 'https://github.com/pikers/piker/tree/master/piker/brokers/ib' ) + + if not vnc_sockaddr: + log.warning( + no_setup_msg + + + f'REQUIRES A `vnc_addrs: array` ENTRY' + ) + + vnc_host, vnc_port = vnc_sockaddr.get( + api_port, + ('localhost', 3003) + ) global _reset_tech match _reset_tech: diff --git a/piker/brokers/ib/api.py b/piker/brokers/ib/api.py index 58fd6a1e..75a79dbe 100644 --- a/piker/brokers/ib/api.py +++ b/piker/brokers/ib/api.py @@ -779,6 +779,7 @@ class Client: async def get_quote( self, contract: Contract, + timeout: float = 1, ) -> Ticker: ''' @@ -789,18 +790,19 @@ class Client: contract, snapshot=True, ) - ready = ticker.updateEvent + ready: ticker.TickerUpdateEvent = ticker.updateEvent # ensure a last price gets filled in before we deliver quote warnset: bool = False for _ in range(100): if isnan(ticker.last): - done, pending = await asyncio.wait( - [ready], - timeout=0.01, + # wait for a first update(Event) + tkr = await asyncio.wait_for( + ready, + timeout=timeout, ) - if ready in done: + if tkr: break else: if not warnset: