From 835ad7794c499117c1e9d4ac39a5c60aac4fefb6 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Tue, 7 Dec 2021 15:08:44 -0500 Subject: [PATCH] Don't error on sub removal attempts, feeds need backpressure --- piker/data/feed.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/piker/data/feed.py b/piker/data/feed.py index 337a625c..0ee94ad9 100644 --- a/piker/data/feed.py +++ b/piker/data/feed.py @@ -356,7 +356,10 @@ async def open_feed_bus( f'Stopping {symbol}.{brokername} feed for {ctx.chan.uid}') if tick_throttle: n.cancel_scope.cancel() - bus._subscribers[symbol].remove(sub) + try: + bus._subscribers[symbol].remove(sub) + except ValueError: + log.warning(f'{sub} for {symbol} was already removed?') @asynccontextmanager @@ -520,7 +523,12 @@ async def open_feed( ) as (ctx, (init_msg, first_quotes)), - ctx.open_stream() as stream, + ctx.open_stream( + # XXX: be explicit about stream backpressure since we should + # **never** overrun on feeds being too fast, which will + # pretty much always happen with HFT XD + backpressure=True + ) as stream, ): # we can only read from shm