Skip to content

Commit b6aac60

Browse files
committed
Store references to streaming tasks
This makes sure they don't get garbage collected. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 3fa4c14 commit b6aac60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/frequenz/sdk/microgrid/client/_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ def __init__(
197197
self.target = target
198198
self.api = MicrogridStub(grpc_channel)
199199
self._component_streams: Dict[int, Broadcast[Any]] = {}
200+
self._streaming_tasks: Dict[int, asyncio.Task[None]] = {}
200201
self._retry_spec = retry_spec
201202

202203
async def components(self) -> Iterable[Component]:
@@ -375,7 +376,7 @@ def _get_component_data_channel(
375376
chan = Broadcast[_GenericComponentData](task_name)
376377
self._component_streams[component_id] = chan
377378

378-
asyncio.create_task(
379+
self._streaming_tasks[component_id] = asyncio.create_task(
379380
self._component_data_task(
380381
component_id,
381382
transform,

0 commit comments

Comments
 (0)