Skip to content

Commit

Permalink
BasePolicyWatcherTask: Signal stop if broadcaster fails to connect
Browse files Browse the repository at this point in the history
  • Loading branch information
roekatz committed Jun 27, 2024
1 parent 5857f64 commit 3fba32e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions packages/opal-server/opal_server/policy/watcher/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ async def _subscribe_internal():
)

if self._pubsub_endpoint.broadcaster is not None:
async with self._pubsub_endpoint.broadcaster.get_listening_context():
await _subscribe_internal()
await self._pubsub_endpoint.broadcaster.get_reader_task()

# Stop the watcher if broadcaster disconnects
try:
async with self._pubsub_endpoint.broadcaster.get_listening_context():
await _subscribe_internal()
await self._pubsub_endpoint.broadcaster.get_reader_task()
finally:
# Stop the watcher if broadcaster disconnects / fails to connect
self.signal_stop()
else:
# If no broadcaster is configured, just subscribe, no need to wait on anything
Expand Down
2 changes: 1 addition & 1 deletion packages/requires.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
idna>=3.3,<4
typer>=0.4.1,<1
fastapi>=0.109.1,<1
fastapi_websocket_pubsub==0.3.7
fastapi_websocket_pubsub==0.3.9
fastapi_websocket_rpc>=0.1.21,<1
gunicorn>=22.0.0,<23
pydantic[email]>=1.9.1,<2
Expand Down

0 comments on commit 3fba32e

Please sign in to comment.