fix: close late scheduler poll during drain

This commit is contained in:
lda
2026-09-09 23:55:13 +07:00 Verified
parent 5d364f005a
commit 939eae85e7
2 changed files with 36 additions and 3 deletions
+17
View File
@@ -457,6 +457,23 @@ async def test_cancelled_resume_release_waits_for_lock_cleanup(
await service.stop()
async def test_poll_once_rejects_after_stop_begins(tmp_path: Path) -> None:
"""A late manual tick cannot enter the scheduler during drain."""
intended = ts(2026, 9, 8, 12, 0)
service = _service(tmp_path, ScriptedRuntime("complete"))
try:
await service.start()
service.schedule_store.create_schedule(_sched_model("a", intended))
service._stopping = True
with pytest.raises(SchedulerStartupError, match="stopping"):
await service.poll_once(intended + timedelta(seconds=1))
assert service.run_store.list_runs() == []
finally:
service._stopping = False
await service.stop()
async def test_scheduled_interrupt_stays_resumable(tmp_path: Path) -> None:
intended = ts(2026, 9, 8, 12, 0)
service = _service(tmp_path, ScriptedRuntime("interrupt"))