-
-
Notifications
You must be signed in to change notification settings - Fork 409
ThreadCache workers leaking spawner's Context on py314+ free-threaded builds #3473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
A5rocks
merged 19 commits into
python-trio:main
from
EmmanuelNiyonshuti:free-threaded-context-leak-threadcache
Jul 16, 2026
+36
−2
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
25bfa7f
Fix ThreadCache workers leaking spawner's Context on py314+ free-thre…
EmmanuelNiyonshuti df6fdaa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7bfb77b
fix typo
EmmanuelNiyonshuti b43e448
add newsfragments
EmmanuelNiyonshuti 31aa1b3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e3881ce
fix typing and reformat newfragments entry
EmmanuelNiyonshuti 9d8f97b
Merge remote-tracking branch 'origin/free-threaded-context-leak-threa…
EmmanuelNiyonshuti 306edad
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0cb179c
add a regression test
EmmanuelNiyonshuti f6c01df
update newfragments entry
EmmanuelNiyonshuti eec08bb
update _thread_cache
EmmanuelNiyonshuti e232d35
Merge remote-tracking branch 'origin/free-threaded-context-leak-threa…
EmmanuelNiyonshuti e114fc0
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 114eb57
update the test to be skipped on pypi
EmmanuelNiyonshuti 0baa9ac
Merge remote-tracking branch 'origin/free-threaded-context-leak-threa…
EmmanuelNiyonshuti edf43b6
update the test
EmmanuelNiyonshuti 1c527cf
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 72aa082
simply regression test
EmmanuelNiyonshuti eb8320f
Merge remote-tracking branch 'origin/free-threaded-context-leak-threa…
EmmanuelNiyonshuti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Fixed ``trio.to_thread.run_sync``` workers leaking spawner's ``Context`` on ``py314t+`` free-threaded builds. |
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO you should just check whether context gets carried over, no need for GC or whatever. Technically there could be a bug where we clear it in the frame before handing it to the user but store it elsewhere -- and you could test for that using weakref (to ensure it works on PyPy) -- but IMO not necessary.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we could use weakref too. I leaned more towards how anyio did it.