我是个新手
asyncio
.
我如何摆脱困境
asyncio.sleep(secs)
?
def onPendingTickers(tickers):
for t in tickers:
print(t)
tz = pytz.timezone('America/Mexico_City')
if datetime.now(tz).time() >= datetime.strptime('13:30', '%H:%M').time():
ib.disconnect()
print('breaking')
ib.pendingTickersEvent += onPendingTickers
ib.sleep(5*60)
conn.close()
ib.pendingTickersEvent -= onPendingTickers
ib.sleep(5*60)
#is where I can't figure out how to break out of
#in case time is above particular time.
这个
sleep
功能:
def sleep(secs: float = 0.02) -> bool:
"""
Wait for the given amount of seconds while everything still keeps
processing in the background. Never use time.sleep().
Args:
secs (float): Time in seconds to wait.
"""
run(asyncio.sleep(secs))
return True
我该如何摆脱困境
ib.sleep()
?
我在哪里可以了解更多信息?