docs/test: align scheduling cleanup

This commit is contained in:
lda
2026-09-10 05:26:40 +07:00 Verified
parent 4474135301
commit 422dd57db6
8 changed files with 59 additions and 35 deletions
+4 -2
View File
@@ -265,8 +265,10 @@ async def test_settlement_does_not_block_the_event_loop(
await service.start()
service.schedule_store.create_schedule(_sched_model("a", intended))
await service.poll_once(intended + timedelta(seconds=1))
await asyncio.sleep(0.05)
assert settlement_started.is_set()
# The worker releases itself after two seconds as failure-safe cleanup.
# Keep this bounded wait shorter than that timeout so the assertion
# observes the intentionally blocked settlement rather than its guard.
assert await asyncio.to_thread(settlement_started.wait, 1.0)
assert not settlement_finished.is_set()
assert service.live_executions == 1
release.set()
+3 -1
View File
@@ -100,7 +100,9 @@ def test_competing_processes_share_the_canonical_lock(tmp_path: Path) -> None:
comp = tmp_path / "composition"
comp.mkdir(parents=True)
sched_store, run_store = _stores(comp)
identity = Path(canonical_lock_root(sched_store.root, run_store.root) or "")
resolved = canonical_lock_root(sched_store.root, run_store.root)
assert resolved is not None
identity = Path(resolved)
holder = SchedulerOwnership(identity, owner="parent").acquire()
try:
script_path = tmp_path / "compete_canonical.py"
+2
View File
@@ -51,6 +51,7 @@ def test_competing_process_cannot_acquire_while_held(tmp_path: Path) -> None:
capture_output=True,
text=True,
timeout=30,
cwd=Path(__file__).resolve().parents[2],
)
assert proc.returncode == 0, proc.stderr
assert "second-owner-rejected" in proc.stdout
@@ -73,6 +74,7 @@ def test_lock_released_on_process_death(tmp_path: Path) -> None:
)
proc = subprocess.Popen(
[sys.executable, str(script_path)],
cwd=Path(__file__).resolve().parents[2],
stdout=subprocess.PIPE,
text=True,
)