From 48493e50b08aaf4aa537a5717cf59c28a17f656c Mon Sep 17 00:00:00 2001 From: goodboy Date: Fri, 30 Jan 2026 18:50:26 -0500 Subject: [PATCH] .ib.feed: only set `feed_is_live` after first quote Move `feed_is_live.set()` to after receiving the first valid quote instead of setting early on venue-closed path. Prevents sampler registration when no live data expected. Also, - drop redundant `.set()` call in quote iteration loop - add TODO note about sleeping until venue opens vs forever - init `first_quote: dict` early for consistency (this commit msg was generated in some part by [`claude-code`][claude-code-gh]) [claude-code-gh]: https://github.com/anthropics/claude-code --- piker/brokers/ib/feed.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/piker/brokers/ib/feed.py b/piker/brokers/ib/feed.py index 5f2c0062..28054da4 100644 --- a/piker/brokers/ib/feed.py +++ b/piker/brokers/ib/feed.py @@ -1115,6 +1115,7 @@ async def stream_quotes( con: Contract = details.contract first_ticker: Ticker|None = None + first_quote: dict[str, Any] = {} timeout: float = 1.6 with trio.move_on_after(timeout) as quote_cs: @@ -1167,15 +1168,14 @@ async def stream_quotes( first_quote, )) - # it's not really live but this will unblock - # the brokerd feed task to tell the ui to update? - feed_is_live.set() - # block and let data history backfill code run. # XXX obvi given the venue is closed, we never expect feed # to come up; a taskc should be the only way to # terminate this task. await trio.sleep_forever() + # + # ^^XXX^^TODO! INSTEAD impl a `trio.sleep()` for the + # duration until the venue opens!! # ?TODO, we could instead spawn a task that waits on a feed # to start and let it wait indefinitely..instead of this @@ -1199,6 +1199,9 @@ async def stream_quotes( 'Rxed init quote:\n' f'{pformat(first_quote)}' ) + # signal `.data.feed` layer that mkt quotes are LIVE + feed_is_live.set() + cs: trio.CancelScope|None = None startup: bool = True iter_quotes: trio.abc.Channel @@ -1252,7 +1255,6 @@ async def stream_quotes( # tick. ticker = await iter_quotes.receive() quote = normalize(ticker) - feed_is_live.set() fqme: str = quote['fqme'] await send_chan.send({fqme: quote})