mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-06-13 08:51:07 +00:00
fix: clear subscriber map on shutdown
Even though it is not a case in the application, the interface could be used externally
This commit is contained in:
@@ -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]]:
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user