Repository navigation
Conversation
DABH
marked this pull request as ready for review
November 13, 2026 05:52
Objects a test leaves in reference cycles were collected whenever an allocation crossed the collector's threshold, which could be on a workflow thread in the middle of a sandboxed import. redis-py's ConnectionPool.__del__ runs an import, and on CPython before 3.12 an import started by a finalizer while the same thread is inside importlib's module-lock acquire leaks that lock (python/cpython#91351), so the next sandbox import of that module waits forever. That is the Python 3.10 CI stall. An autouse fixture now collects on the main thread after every test.
DABH
force-pushed
the
gc-between-tests
branch
from
November 13, 2026 18:33
1feba72 to
f463165
Compare
DABH
enabled auto-merge (squash)
November 13, 2026 19:27
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.
Tests sometimes stall (fail) on CPython < 3.12 if we don't garbage collect between tests. This is pretty low level and required a lot of prodding but I was able to reproduce the bad/good behavior without/with this fix consistently.
Specifically, objects a test leaves in reference cycles are collected whenever an allocation crosses the collector's threshold, which can be on a workflow thread in the middle of a sandboxed import. redis-py's
ConnectionPool.__del__runs an import, and on CPython before 3.12 an import started by a finalizer while the same thread is inside importlib's module-lock acquire leaks that lock (python/cpython#91351). The next sandbox import of that module waits forever, which is the stall I was seeing in various tests today. Every stalled log I encountered shows the importlibKeyErrorduring the ADK agent-patterns test, whereas no passing log does.