Skip to content

Commit

Permalink
Add GrpcStreamBroadcaster.is_running method
Browse files Browse the repository at this point in the history
Based on how it is configured, the `GrpcStreamBroadcaster` can stop
running when the retry limit has been reached or when the server
closes the connection.

The `is_running` method can be used to find out if that has happened.

Signed-off-by: Sahas Subramanian <[email protected]>
  • Loading branch information
shsms committed Oct 25, 2024
1 parent b4c1883 commit f315f0f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/frequenz/client/base/streaming.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ def new_receiver(self, maxsize: int = 50) -> channels.Receiver[OutputT]:
"""
return self._channel.new_receiver(limit=maxsize)

@property
def is_running(self) -> bool:
"""Return whether the streaming helper is running.
Returns:
Whether the streaming helper is running.
"""
return not self._task.done()

async def stop(self) -> None:
"""Stop the streaming helper."""
if self._task.done():
Expand Down

0 comments on commit f315f0f

Please sign in to comment.