From 78fe0986fce55c07cf12bc8127dad300f0fa6bf9 Mon Sep 17 00:00:00 2001 From: Nelson Torres Date: Thu, 30 Jan 2025 01:40:20 +0000 Subject: [PATCH] maybe_open_oi_feed --- piker/brokers/deribit/api.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/piker/brokers/deribit/api.py b/piker/brokers/deribit/api.py index b206a425..50863f1e 100644 --- a/piker/brokers/deribit/api.py +++ b/piker/brokers/deribit/api.py @@ -856,6 +856,20 @@ async def open_oi_feed( yield chan +@acm +async def maybe_open_oi_feed( +) -> trio.abc.ReceiveStream: + + # TODO: add a predicate to maybe_open_context + feed: to_asyncio.LinkedTaskChannel + async with maybe_open_context( + acm_func=open_oi_feed, + ) as (cache_hit, feed): + if cache_hit: + yield broadcast_receiver(feed, 10) + else: + yield feed + # TODO, move all to `.broker` submod! # async def aio_order_feed_relay(