Repository navigation
R1: lifetime tests collect only what they allocate (unit-tests timeout) - #1213
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What was wrong
tests/unit/test_custom_function_events.py::test_qt_adapter_mixed_native_lifetime_orders[*](four cases) each hit the 120 s pytest timeout in theunit-testsjob (CI run38155492658, about 527 s for the file), which contributed to the job being cancelled at 45 minutes. The file makes about 200 fullgc.collect()calls, and late in the unit session each full collection walks the whole session heap (more than 3 s per call).Change (tests only)
gc.freeze()before each test andgc.unfreeze()after. Objects allocated earlier in the session move to the permanent generation, so each collection covers exactly what the test allocates.test_collection_under_the_frozen_heap_still_reclaims_new_cycles: a fresh self-referencing object is alive beforegc.collect()and reclaimed after it, under the fixture.docs/refactor/consolidation-20261009/R1-release-blockers.md(item 3).Assertions before and after
The diff to the test file is 30 added lines and no removed or edited line: every existing assertion is unchanged. The lifetime tests assert that weak references to adapters, subscribers and signal objects are dead after
gc.collect()for every destruction order, and that no callback fires after cancellation. Freezing cannot make these weaker: a frozen object is treated as a live external root, so a test object that is still referenced from the earlier heap stays alive and the assertion fails, exactly as before. Nothing had to be restored.Verification (local, Linux, merged with
origin/mainae6ddace5)tests/unit/test_custom_function_events.pyalone:11 passed in 1.17s.tests/unit/test_custom_function_lifecycle.py,-n 2:66 passed in 55.50s.guardrails_local.sh:guardrails rc=0(three ratchets exit 0, 38 guardrail tests passed, nra-r1"increased": []).SMOKE_SKIP_GUI=1 smoke_local.sh:5 passed,smoke rc=0.Note: the sibling PR for
refactor/R1-selected-source-discoveryadds the same receipt file; whichever merges second needs a trivial merge of that document.R1 (item 3) · PR #1213 · guards 1/1 · production −0 +0 · tests −0 +30
🤖 Generated with Claude Code