Skip to content

Commit

Permalink
Store references to streaming tasks (#616)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-zullo-frequenz authored Aug 30, 2023
2 parents 3fa4c14 + 07cd99b commit eabef0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Bug Fixes

- Ping `pypantic` version to `< 2`.
- Hold on to a reference to all streaming tasks in the microgrid API client, so they don't get garbage collected.
3 changes: 2 additions & 1 deletion src/frequenz/sdk/microgrid/client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def __init__(
self.target = target
self.api = MicrogridStub(grpc_channel)
self._component_streams: Dict[int, Broadcast[Any]] = {}
self._streaming_tasks: Dict[int, asyncio.Task[None]] = {}
self._retry_spec = retry_spec

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

asyncio.create_task(
self._streaming_tasks[component_id] = asyncio.create_task(
self._component_data_task(
component_id,
transform,
Expand Down

0 comments on commit eabef0c

Please sign in to comment.