Skip to content

Commit 48ce9dc

Browse files
authored
test: fix flaky timing in test_cancel_terminated_invocation (#619)
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 <fgmacedo@gmail.com>
1 parent 847f1d5 commit 48ce9dc

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

tests/test_invoke.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,10 @@ class SM(StateChart):
614614
done_invoke_loading = loading.to(ready)
615615

616616
sm = await sm_runner.start(SM)
617-
await sm_runner.sleep(0.15)
618-
await sm_runner.processing_loop(sm)
617+
deadline = time.monotonic() + 2.0
618+
while "ready" not in sm.configuration_values and time.monotonic() < deadline:
619+
await sm_runner.sleep(0.02)
620+
await sm_runner.processing_loop(sm)
619621

620622
assert "ready" in sm.configuration_values
621623
# All invocations should be terminated by now

0 commit comments

Comments
 (0)