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)
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:

View File

@ -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: