diff --git a/src/ahriman/core/status/event_bus.py b/src/ahriman/core/status/event_bus.py index c1378712..e8f87114 100644 --- a/src/ahriman/core/status/event_bus.py +++ b/src/ahriman/core/status/event_bus.py @@ -99,6 +99,7 @@ class EventBus(LazyLogging): async with self._lock: for subscription in self._subscribers.values(): subscription.queue.shutdown() + self._subscribers.clear() async def subscribe(self, topics: list[EventType] | None = None, object_id: str | None = None) -> tuple[str, Queue[SSEvent]]: diff --git a/src/ahriman/web/views/v1/auditlog/event_bus.py b/src/ahriman/web/views/v1/auditlog/event_bus.py index c4c2b0b8..b39ba02b 100644 --- a/src/ahriman/web/views/v1/auditlog/event_bus.py +++ b/src/ahriman/web/views/v1/auditlog/event_bus.py @@ -101,7 +101,9 @@ class EventBusView(BaseView): @apidocs( tags=["Audit log"], summary="Live updates", - description="Stream live updates via SSE", + description="Stream live updates via SSE. Read-only users may subscribe only when all requested event filters " + "belong to read-safe package and service status events; build log or unfiltered streams require " + "full access. Streams are live-only and do not replay missed events after reconnect.", permission=UserAccess.Full, error_400_enabled=True, error_404_description="Repository is unknown", diff --git a/tests/ahriman/core/status/test_event_bus.py b/tests/ahriman/core/status/test_event_bus.py index 5c5d7996..467146fa 100644 --- a/tests/ahriman/core/status/test_event_bus.py +++ b/tests/ahriman/core/status/test_event_bus.py @@ -65,9 +65,10 @@ async def test_shutdown(event_bus: EventBus) -> None: """ must shutdown all subscriber queues on shutdown """ - _, queue = await event_bus.subscribe() + subscriber_id, queue = await event_bus.subscribe() await event_bus.shutdown() + assert subscriber_id not in event_bus._subscribers with pytest.raises(QueueShutDown): queue.get_nowait()