From e5e19161294c32d0fbcd8a1557528acf84ca8ee5 Mon Sep 17 00:00:00 2001 From: Roland Date: Wed, 19 Aug 2026 19:09:16 -0600 Subject: [PATCH] test: the watchdog test must not inherit a sibling's shutdown state perpetual_shutdown is set by the real before_server_stop listener, so any earlier async_client teardown in the same pytest-xdist worker leaves it True on the module-global app and the watchdog returns before reclaiming. Failed under -nauto, passed alone. Co-Authored-By: Claude Fable 5 --- wrolpi/test/test_api_utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/wrolpi/test/test_api_utils.py b/wrolpi/test/test_api_utils.py index eb237c0d..43847207 100644 --- a/wrolpi/test/test_api_utils.py +++ b/wrolpi/test/test_api_utils.py @@ -180,6 +180,12 @@ async def test_watchdog_reclaims_and_starts_pumps_when_owner_is_dead(async_clien async def fake_dispatch(event): dispatched.append(event) + # A sibling test's async_client teardown runs the real before_server_stop listener, + # which leaves perpetual_shutdown=True on the module-global app; the watchdog would + # then return before reclaiming. This test is about a dead owner, not shutdown. + monkeypatch.setattr(api_app.ctx, 'perpetual_shutdown', False, raising=False) + monkeypatch.setattr(api_app.state, 'is_stopping', False, raising=False) + api_app.shared_ctx.perpetual_tasks_started.set() api_app.shared_ctx.perpetual_tasks_owner_pid.value = 2**31 - 1 monkeypatch.setattr('wrolpi.api_utils._dispatch_perpetual', fake_dispatch)