Skip to content

Commit eabef0c

Browse files
Store references to streaming tasks (#616)
2 parents 3fa4c14 + 07cd99b commit eabef0c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

RELEASE_NOTES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
## Bug Fixes
44

5-
- Ping `pypantic` version to `< 2`.
5+
- Hold on to a reference to all streaming tasks in the microgrid API client, so they don't get garbage collected.

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

+2-1
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)