Skip to content

Commit 79a261c

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 953e320 commit 79a261c

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
@@ -216,6 +216,7 @@ def __init__(
216216
self.target = target
217217
self.api = MicrogridStub(grpc_channel)
218218
self._component_streams: Dict[int, Broadcast[Any]] = {}
219+
self._streaming_tasks: Dict[int, asyncio.Task[None]] = {}
219220
self._retry_spec = retry_spec
220221

221222
async def components(self) -> Iterable[Component]:
@@ -401,7 +402,7 @@ def _get_component_data_channel(
401402
chan = Broadcast[_GenericComponentData](task_name)
402403
self._component_streams[component_id] = chan
403404

404-
asyncio.create_task(
405+
self._streaming_tasks[component_id] = asyncio.create_task(
405406
self._component_data_task(
406407
component_id,
407408
transform,

0 commit comments

Comments
 (0)