Don't sleep on less than zero delay

kivy_mainline_and_py3.8
Tyler Goodlet 2018-02-13 12:13:04 -05:00
parent 472ff68811
commit 62bac7b2cd
1 changed files with 4 additions and 2 deletions

View File

@ -328,8 +328,9 @@ async def poll_tickers(
last = _cache.setdefault(symbol, {}) last = _cache.setdefault(symbol, {})
timekey = 'lastTradeTime' timekey = 'lastTradeTime'
if quote[timekey] != last.get(timekey): if quote[timekey] != last.get(timekey):
new = set(quote.items()) - set(last.items())
log.info( log.info(
f"New quote {quote['symbol']} @ {quote[timekey]}") f"New quote {quote['symbol']} @ {quote[timekey]}:\n{new}")
_cache[symbol] = quote _cache[symbol] = quote
payload.append(quote) payload.append(quote)
else: else:
@ -342,6 +343,7 @@ async def poll_tickers(
delay = sleeptime - proc_time delay = sleeptime - proc_time
if delay <= 0: if delay <= 0:
log.warn(f"Took {proc_time} seconds for processing quotes?") log.warn(f"Took {proc_time} seconds for processing quotes?")
else:
await trio.sleep(delay) await trio.sleep(delay)