Repository navigation
test(execution): stop processor cancel tests timing out behind a full GC per item - #9949
Merged
Pfannkuchensack merged 1 commit intoOct 19, 2026
Conversation
… GC per item Skip the worker's per-item gc.collect() in the session-processor tests; late in an xdist session it took seconds, past the 5 s waits that failed. Give the For SQLite tests one 30 s hang ceiling, like the If tests.
joshistoast
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The flaky session-processor cancel/retry tests in #9948 never lost an event; the processor reached the item too late for the test's wait.
DefaultSessionProcessor._processruns a fullgc.collect()before every item it claims, and late in an xdist session that walks a heap of 3–5 million objects. Every failure cited in the issue was a 5 s wait. The If failures came from #9910's branch, which predated the 30 s ceiling from #9940, and the flat For test still waited 5 s onmain.gc, so the globalgc.collectis untouched. None of these tests check memory.test_for_loop_processor_sqlite.pygets one 30 s hang ceiling,_PROCESSOR_TIMEOUT, liketest_if_processor_sqlite.py. It is thewait_for_statusdefault and the shutdown join timeout, and it replaces the per-testtest_timeoutlocals and the remaining 5 s waits.A cancel issued from
on_after_run_noderuns on the runner thread, and the guarded status transition always emits thecanceledevent, so no production change is needed.Related Issues / Discussions
Closes #9948
QA Instructions
gc.collectsleep 6 s and runpytest tests/app/services/session_processor/test_for_loop_processor_sqlite.py -k flat_for_cancel. Before this PR it fails atwait_for_status(1, 'canceled')(line 1696), the same as CI. After this PR, with every claim attempt delayed 6 s instead, the flat For test (12 s) and the If early-cancellation test (6 s) pass.pytest tests -n 4 -m "not slow"): 2.96 s mean and 3.87 s max per call in the For/If SQLite tests, against 0.66 s per item in a fresh single-test process. A loaded two-worker Windows runner ends up above 5 s.pytest tests/app/services/session_processor: 119 passed. The run took 43 s before and 11 s after; the flat For test dropped from about 1.8 s to under 0.21 s. Each changed file also passes on its own.ruff checkandruff format --check(0.11.2) pass on the changed files.Review
No material findings. Each processor item still pays a full
gc.collect()in production too. That is left for a separate, measured change.Checklist
What's Newcopy (if doing a release after this PR)Need help on this PR? Tag
@codesmith-botwith what you need.