feat(remote): end a remote session when its client is gone

This commit is contained in:
imSp4rky
2026-11-30 17:23:35 -07:00
parent e813737506
commit ffe812f054
13 changed files with 747 additions and 53 deletions
+12
View File
@@ -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))