From 2f114d8b7b1a93d30790ff70bbac3977a646a0a5 Mon Sep 17 00:00:00 2001 From: dydydd Date: Wed, 16 Sep 2026 07:52:53 +0800 Subject: [PATCH] Let the killed-child supervisor test allow more than two attempts On a busy CI runner the second holder can miss a lease renewal with --lock-timeout 0.5, the reaper hands the task back, and a third claim runs it -- at-least-once execution doing its job: the stale run is refused (lost its lease) and the task still ends SUCCESSFUL. Assert what the worker promises instead of an exact count: attempts >= 2, one worker id per attempt, the first holder unchanged, and the lease-loss log line when a third attempt happens. Closes #47 --- tests/test_supervisor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test_supervisor.py b/tests/test_supervisor.py index 71c4319..f78b081 100644 --- a/tests/test_supervisor.py +++ b/tests/test_supervisor.py @@ -306,9 +306,14 @@ def test_killed_child_is_restarted_and_its_task_reaped(self, tmp_path): r"Worker process \d exited with signal SIGKILL; restarting", log ) row = OxTask.objects.get(id=result.id) - assert row.attempts == 2 - assert len(row.worker_ids) == 2 + # At-least-once execution: on a slow runner the second holder can + # miss a lease renewal, the reaper hands the task back, and a third + # claim runs it. Assert what the worker promises, not an exact count. + assert row.attempts >= 2 + assert len(row.worker_ids) == row.attempts assert row.worker_ids[0] == holder + if row.attempts > 2: + assert "lost its lease" in log class TestReinvocation: