From 62bac7b2cdd235f3dd705043641b1c83d87b665c Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 13 Feb 2018 12:13:04 -0500 Subject: [PATCH] Don't sleep on less than zero delay --- piker/brokers/questrade.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/piker/brokers/questrade.py b/piker/brokers/questrade.py index bb5eb741..3f7cee8b 100644 --- a/piker/brokers/questrade.py +++ b/piker/brokers/questrade.py @@ -328,8 +328,9 @@ async def poll_tickers( last = _cache.setdefault(symbol, {}) timekey = 'lastTradeTime' if quote[timekey] != last.get(timekey): + new = set(quote.items()) - set(last.items()) log.info( - f"New quote {quote['symbol']} @ {quote[timekey]}") + f"New quote {quote['symbol']} @ {quote[timekey]}:\n{new}") _cache[symbol] = quote payload.append(quote) else: @@ -342,7 +343,8 @@ async def poll_tickers( delay = sleeptime - proc_time if delay <= 0: log.warn(f"Took {proc_time} seconds for processing quotes?") - await trio.sleep(delay) + else: + await trio.sleep(delay) async def api(methname: str, **kwargs) -> dict: