mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 12:35:13 +00:00
fix(api): stop serve cleanly with jobs, streams and remote sessions open
This commit is contained in:
@@ -175,6 +175,30 @@ async def test_events_burst_mode(aiohttp_client, dashboard_cfg) -> None:
|
||||
assert [e["data"]["action"] for e in body["events"] if e["event"] == "session"] == ["create", "delete"]
|
||||
|
||||
|
||||
def test_bus_close_ends_a_full_subscriber_queue() -> None:
|
||||
local = EventBus()
|
||||
queue: asyncio.Queue = asyncio.Queue(maxsize=1)
|
||||
local._subs.append(queue)
|
||||
local.publish("session", {"action": "create"})
|
||||
local.close()
|
||||
assert queue.get_nowait() is None
|
||||
|
||||
|
||||
async def test_the_event_stream_ends_at_serve_shutdown(aiohttp_client, dashboard_cfg) -> None:
|
||||
from unshackle.core.api.download_manager import shutdown_download_manager
|
||||
from unshackle.core.api.events import close_event_streams
|
||||
|
||||
app = make_app()
|
||||
assert {close_event_streams, shutdown_download_manager} <= set(app.on_shutdown)
|
||||
client = await aiohttp_client(app)
|
||||
resp = await client.get("/api/dashboard/events", headers={"X-Secret-Key": "dash-secret"})
|
||||
assert resp.status == 200
|
||||
await asyncio.wait_for(resp.content.readuntil(b"\n\n"), timeout=10)
|
||||
await close_event_streams(app)
|
||||
await asyncio.wait_for(resp.content.read(), timeout=10)
|
||||
assert resp.content.at_eof()
|
||||
|
||||
|
||||
async def test_session_action_log() -> None:
|
||||
store = SessionStore()
|
||||
entry = await store.create("EXAMPLE", object(), owner_key="k")
|
||||
|
||||
Reference in New Issue
Block a user