From 719187bf5a5c9e1bb1d4b38e299ca56a74a1ffdd Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 9 Dec 2021 08:21:35 -0500 Subject: [PATCH] WIP idea: drain feed stream, doesn't do much.. --- piker/ui/_display.py | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/piker/ui/_display.py b/piker/ui/_display.py index c2333350..bfb54ee2 100644 --- a/piker/ui/_display.py +++ b/piker/ui/_display.py @@ -182,29 +182,28 @@ async def update_linked_charts_graphics( view = chart.view last_quote = time.time() - # async def iter_drain_quotes(): - # # NOTE: all code below this loop is expected to be synchronous - # # and thus draw instructions are not picked up jntil the next - # # wait / iteration. - # async for quotes in stream: - # while True: - # try: - # moar = stream.receive_nowait() - # except trio.WouldBlock: - # yield quotes - # break - # else: - # for sym, quote in moar.items(): - # ticks_frame = quote.get('ticks') - # if ticks_frame: - # quotes[sym].setdefault( - # 'ticks', []).extend(ticks_frame) - # print('pulled extra') + async def iter_drain_quotes(): + # NOTE: all code below this loop is expected to be synchronous + # and thus draw instructions are not picked up jntil the next + # wait / iteration. + async for quotes in stream: + while True: + try: + moar = stream.receive_nowait() + except trio.WouldBlock: + yield quotes + break + else: + for sym, quote in moar.items(): + ticks_frame = quote.get('ticks') + if ticks_frame: + quotes[sym].setdefault( + 'ticks', []).extend(ticks_frame) + print('pulled extra') - # yield quotes + yield quotes # async for quotes in iter_drain_quotes(): - async for quotes in stream: quote_period = time.time() - last_quote