ib: use `asyncio.wait_for()` on ticker first quote; on 3.11 input coros are not allowed..

ib_py311_fixes
Tyler Goodlet 2023-08-16 16:57:11 -04:00
parent 94540ce1cf
commit 0068119a6d
2 changed files with 22 additions and 11 deletions

View File

@ -88,16 +88,25 @@ async def data_reset_hack(
api_port: str = str(ib_client.client.port) api_port: str = str(ib_client.client.port)
vnc_host: str vnc_host: str
vnc_port: int vnc_port: int
vnc_host, vnc_port = client.conf['vnc_addrs'].get( vnc_sockaddr: tuple[str] | None = client.conf.get('vnc_addrs')
api_port,
('localhost', 3003)
)
no_setup_msg:str = ( no_setup_msg:str = (
f'No data reset hack test setup for {vnc_host}!\n' f'No data reset hack test setup for {vnc_sockaddr}!\n'
'See setup @\n' 'See config setup tips @\n'
'https://github.com/pikers/piker/tree/master/piker/brokers/ib' '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 global _reset_tech
match _reset_tech: match _reset_tech:

View File

@ -779,6 +779,7 @@ class Client:
async def get_quote( async def get_quote(
self, self,
contract: Contract, contract: Contract,
timeout: float = 1,
) -> Ticker: ) -> Ticker:
''' '''
@ -789,18 +790,19 @@ class Client:
contract, contract,
snapshot=True, snapshot=True,
) )
ready = ticker.updateEvent ready: ticker.TickerUpdateEvent = ticker.updateEvent
# ensure a last price gets filled in before we deliver quote # ensure a last price gets filled in before we deliver quote
warnset: bool = False warnset: bool = False
for _ in range(100): for _ in range(100):
if isnan(ticker.last): if isnan(ticker.last):
done, pending = await asyncio.wait( # wait for a first update(Event)
[ready], tkr = await asyncio.wait_for(
timeout=0.01, ready,
timeout=timeout,
) )
if ready in done: if tkr:
break break
else: else:
if not warnset: if not warnset: