Repository navigation
Conversation
Fix handle leaks in test_tcl when the test is run with -R 3:3. Call explicitly Tcl_FinalizeThread() in test_returning_deeply_nested() to clean up explicitly per-thread state. The test is run in a thread because of the @run_with_limited_c_stack() decorator. On Windows, Tcl_CreateInterp() creates an event in the Tcl notifier implementation. The event is stored in per-thread state which is only cleaned up at exit. Add _tkinter.finalize_thread() function.
|
See #161353 (comment) for the longer rationale. @serhiy-storchaka @terryjreedy @gpshead: Would you mind to review my fix? |
|
This fix should be backported to 3.15 once #161071 will be merged. |
|
An alternative would be to register an atexit callback with I mean, I don't understand well if the handle leak (one Windows event) only impacts tests, or call impact real Python code. |
|
!buildbot AMD64.Windows.Server.2025.Refleaks. |
|
🤖 New build scheduled with the buildbot fleet by @encukou for commit bc80f6a 🤖 Results will be shown at: https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F161368%2Fmerge The command will test the builders whose names match following regular expression: The builders matched are:
|
|
|
|
Well, the simplest fix is to skip the test in the leak-hunting mode. The leak is still here, but it is small, and once per thread. |
In my PR, _tkinter.finalize_thread() is called when the thread exits, so I'm not sure of what you mean by "later"? Do you mean executing more Tcl/Tk code after calling _tkinter.finalize_thread()? Would you prefer to rename the function to |
|
Adding an underscore and changing the docstring will help. But skipping the test is simpler. |
Fix handle leaks in test_tcl when the test is run with -R 3:3. Call explicitly Tcl_FinalizeThread() in test_returning_deeply_nested() to clean up explicitly per-thread state. The test is run in a thread because of the
@run_with_limited_c_stack()decorator.On Windows, Tcl_CreateInterp() creates an event in the Tcl notifier implementation. The event is stored in per-thread state which is only cleaned up at exit.
Add _tkinter.finalize_thread() function.