Repository navigation
gh-162724: Free per-thread Tcl resources at thread exit in tkinter - #162725
Conversation
Call Tcl_FinalizeThread() when the Python thread state is cleared at the end of a thread which made calls to a Tcl interpreter in other thread or created a Tcl interpreter, unless the thread still has a Tcl interpreter. This fixes a leak of an event handle on Windows for every such thread. The explicit _tkinter._finalize_thread() calls in tests are no longer needed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This is failing at "Check for unsupported C global variables": https://github.com/python/cpython/actions/runs/45971574485/job/140413191394?pr=162725 |
|
!buildbot Windows Server 2025 Refleaks |
|
🤖 New build scheduled with the buildbot fleet by @hugovk for commit 939c21a 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F162725%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
|
!buildbot Windows Server 2025 Refleaks |
|
🤖 New build scheduled with the buildbot fleet by @zware for commit 0fab0c8 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F162725%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
|
Thanks @serhiy-storchaka for the PR, and @encukou for merging it 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15. |
|
Sorry, @serhiy-storchaka and @encukou, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @serhiy-storchaka and @encukou, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
GH-163152 is a backport of this pull request to the 3.15 branch. |
|
GH-163153 is a backport of this pull request to the 3.14 branch. |
…nter (GH-162725) (GH-163152) Call Tcl_FinalizeThread() when the Python thread state is cleared at the end of a thread which made calls to a Tcl interpreter in other thread or created a Tcl interpreter, unless the thread still has a Tcl interpreter. This fixes a leak of an event handle on Windows for every such thread. The explicit _tkinter._finalize_thread() calls in tests are no longer needed. (cherry picked from commit f16b34a)
…nter (GH-162725) (GH-163153) Call Tcl_FinalizeThread() when the Python thread state is cleared at the end of a thread which made calls to a Tcl interpreter in other thread or created a Tcl interpreter, unless the thread still has a Tcl interpreter. This fixes a leak of an event handle on Windows for every such thread. (cherry picked from commit f16b34a)
Call
Tcl_FinalizeThread()when the Python thread state is cleared at the end of a thread which made calls to a Tcl interpreter in other thread or created a Tcl interpreter, unless the thread still has a live Tcl interpreter. This frees the per-thread Tcl resources, including the event handle which Tcl creates on Windows for every thread which waits for a call to an interpreter in other thread.This fixes the handle leak in
test_nested_mainloopon the Windows refleak buildbot reported in #162651, and the root cause of #161353, so the explicit_tkinter._finalize_thread()calls in tests are no longer needed.🤖 Generated with Claude Code