mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-01 21:45:10 +00:00
feat(remote): end a remote session when its client is gone
This commit is contained in:
@@ -216,6 +216,18 @@ async def test_max_sessions_evicts_the_oldest_session_of_the_key_that_holds_the_
|
||||
assert set(store._sessions) == {"a-1", "b-2", "b-3"}
|
||||
|
||||
|
||||
async def test_max_sessions_evicts_a_session_with_work_in_progress_last(
|
||||
store: SessionStore, monkeypatch: pytest.MonkeyPatch
|
||||
) -> None:
|
||||
monkeypatch.setattr(type(store), "max_sessions", property(lambda _: 2))
|
||||
busy = await store.create("EXAMPLE", _FakeService(), session_id="busy")
|
||||
async with busy.lock:
|
||||
await asyncio.sleep(0.01)
|
||||
await store.create("EXAMPLE", _FakeService(), session_id="idle")
|
||||
await store.create("EXAMPLE", _FakeService(), session_id="new")
|
||||
assert set(store._sessions) == {"busy", "new"}
|
||||
|
||||
|
||||
async def test_get_expiry_removes_cache_dir(store: SessionStore, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
removed: list = []
|
||||
monkeypatch.setattr(SessionStore, "cleanup_cache_dir", staticmethod(removed.append))
|
||||
|
||||
Reference in New Issue
Block a user