Comment stream drain idea

Likely it's not going to be that useful but keep it for reference for
the moment.
vlm_plotz
Tyler Goodlet 2021-12-20 13:53:29 -05:00
parent 719187bf5a
commit c58a56fca7
1 changed files with 20 additions and 19 deletions

View File

@ -182,28 +182,29 @@ async def update_linked_charts_graphics(
view = chart.view view = chart.view
last_quote = time.time() last_quote = time.time()
async def iter_drain_quotes(): # async def iter_drain_quotes():
# NOTE: all code below this loop is expected to be synchronous # # NOTE: all code below this loop is expected to be synchronous
# and thus draw instructions are not picked up jntil the next # # and thus draw instructions are not picked up jntil the next
# wait / iteration. # # wait / iteration.
async for quotes in stream: # async for quotes in stream:
while True: # while True:
try: # try:
moar = stream.receive_nowait() # moar = stream.receive_nowait()
except trio.WouldBlock: # except trio.WouldBlock:
yield quotes # yield quotes
break # break
else: # else:
for sym, quote in moar.items(): # for sym, quote in moar.items():
ticks_frame = quote.get('ticks') # ticks_frame = quote.get('ticks')
if ticks_frame: # if ticks_frame:
quotes[sym].setdefault( # quotes[sym].setdefault(
'ticks', []).extend(ticks_frame) # 'ticks', []).extend(ticks_frame)
print('pulled extra') # print('pulled extra')
yield quotes # yield quotes
# async for quotes in iter_drain_quotes(): # async for quotes in iter_drain_quotes():
async for quotes in stream: async for quotes in stream:
quote_period = time.time() - last_quote quote_period = time.time() - last_quote