Repository navigation
TEST: Join SQLite cleanup workers before leak checks - #3362
Merged
Roman Lutz (romanlutz) merged 2 commits intoOct 20, 2026
Merged
Roman Lutz (romanlutz) merged 2 commits into
Roman Lutz (romanlutz) merged 2 commits into
Conversation
Run the fixture GC regression in an isolated asyncio.Runner so executor work items release bound disposal methods before collection. Keep the weak-reference assertion and real cleanup checks. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ac1d8921-cfc7-4a1c-bf94-cc7c7bf51566
Roman Lutz (romanlutz)
approved these changes
Oct 20, 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.
Description
Fix the intermittent GC assertion in
test_sqlite_instance_does_not_retain_process_exit_cleanup. It failed in the Windows Python 3.13 dev merge-group job 118365076379 while checking #3206.dispose_engine_asyncawaitsrun_legacy_sync_async(self._dispose_sync_engine), which usesasyncio.to_thread. A thread-pool future can notify the event loop before its worker deletes the work item. That work item still holds the bound disposal method and thus the memory instance.gc.collect()cannot collect a live reference. This is a test lifetime race, not a process-exit hook leak or a result of #3206's seed-storage changes.Run the existing fixture lifecycle in its own
asyncio.Runner. Exit the runner to join its default executor before the unchanged GC and weak-reference assertion. Keep the checks that the real cleanup method is restored. No production code, shared fixture, timeout, retry, or leak assertion changes. This does not duplicate #3361 or #3344.Tests and Documentation
uv sync --frozen --extra all— passed; lockfile unchanged.uv run --no-sync pytest tests\unit\memory\test_sqlite_fixtures.py -q— passed, 14 tests on Windows Python 3.14.2.$env:UV_NO_SYNC='1'; uv run --no-sync pre-commit run --all-files— all hooks passed.git --no-pager diff --check— passed.ThreadPoolExecutorimmediately after_WorkItem.runcompletes; release the worker when executor shutdown starts. The old GC assertion failed 10/10 times. The corrected test passed 10/10 times. Direct referrers included the bound disposal method and its coroutine.atexitafter disposal. The corrected test still fails its weak-reference assertion, as required. The harness unregisters the callback afterward.No documentation or notebook behavior changes; JupyText was not run. The full unit suite and the exact CI Python 3.13 environment were not run locally.