From 823bd2ea295c56f563a2630fca6cabdbd252a93d Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 29 Mar 2018 13:00:48 -0400 Subject: [PATCH] Make payload a ticker dict --- piker/brokers/core.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/piker/brokers/core.py b/piker/brokers/core.py index 0290e0cf..36b9cb3a 100644 --- a/piker/brokers/core.py +++ b/piker/brokers/core.py @@ -66,28 +66,24 @@ async def poll_tickers( prequote_start = time.time() quotes = await get_quotes(tickers) postquote_start = time.time() - payload = [] + payload = {} for symbol, quote in quotes.items(): # FIXME: None is returned if a symbol can't be found. # Consider filtering out such symbols before starting poll loop if quote is None: continue - if quote.get('delay', 0) > 0: - log.warning(f"Delayed quote:\n{quote}") - if diff_cached: # if cache is enabled then only deliver "new" changes - symbol = quote['symbol'] last = _cache.setdefault(symbol, {}) new = set(quote.items()) - set(last.items()) if new: log.info( f"New quote {quote['symbol']}:\n{new}") _cache[symbol] = quote - payload.append(quote) + payload[symbol] = quote else: - payload.append(quote) + payload[symbol] = quote if payload: q.put_nowait(payload)