From eab55c629a771d3d37e7281fa3b1d79b3af85e6a Mon Sep 17 00:00:00 2001 From: Fernando Macedo Date: Fri, 15 May 2026 12:27:59 -0300 Subject: [PATCH] test: fix flaky timing in test_cancel_terminated_invocation Replace the fixed 150ms sleep with a deadline-bounded poll loop. On slower CI runners (e.g., Python 3.11 on GitHub Actions) the executor had not yet posted done.invoke.loading when the assertion ran, leaving the configuration in 'loading' instead of 'ready'. The new loop drives the processing loop in 20ms ticks until the final state is reached, with a 2s ceiling. Signed-off-by: Fernando Macedo --- tests/test_invoke.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_invoke.py b/tests/test_invoke.py index 1e420030..4298e3a9 100644 --- a/tests/test_invoke.py +++ b/tests/test_invoke.py @@ -614,8 +614,10 @@ class SM(StateChart): done_invoke_loading = loading.to(ready) sm = await sm_runner.start(SM) - await sm_runner.sleep(0.15) - await sm_runner.processing_loop(sm) + deadline = time.monotonic() + 2.0 + while "ready" not in sm.configuration_values and time.monotonic() < deadline: + await sm_runner.sleep(0.02) + await sm_runner.processing_loop(sm) assert "ready" in sm.configuration_values # All invocations should be terminated by now