fix(runtime): recover awake ownership and batch model failures
This commit is contained in:
1 parent
6b2c0f199d
commit
baf069854b
17 files changed
+477
-32
No files matched your search
@@ -6,6 +6,40 @@ import pytest
|
||||
from artemis.services import llm
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("replace_pause", [False, True])
|
||||
async def test_cancelled_wait_clears_only_its_own_pause(tmp_path, monkeypatch, replace_pause):
|
||||
pause = tmp_path / "pause"
|
||||
pause.write_text("old request")
|
||||
entered = asyncio.Event()
|
||||
|
||||
async def wait(_seconds):
|
||||
entered.set()
|
||||
await asyncio.Event().wait()
|
||||
|
||||
monkeypatch.setattr(llm.asyncio, "sleep", wait)
|
||||
task = asyncio.create_task(llm._wait_for_resume(pause))
|
||||
await entered.wait()
|
||||
if replace_pause:
|
||||
pause.write_text("a newer request owns this pause")
|
||||
task.cancel()
|
||||
with pytest.raises(asyncio.CancelledError):
|
||||
await task
|
||||
assert pause.exists() is replace_pause
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_pause_deadline_clears_file(tmp_path, monkeypatch):
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
pause = tmp_path / "pause"
|
||||
pause.write_text("failed request")
|
||||
monkeypatch.setattr(llm.settings, "LLM_PAUSE_TIMEOUT_SECONDS", 1)
|
||||
monkeypatch.setattr(llm.asyncio, "sleep", AsyncMock())
|
||||
assert await llm._wait_for_resume(pause) is False
|
||||
assert not pause.exists()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_timeout_wrapper_cancels_llm_call_when_caller_is_cancelled():
|
||||
started = asyncio.Event()
|
||||
|
||||
Reference in new issue
Block a user