[issue33412] Tkinter hangs if using multiple threads and event handlers

Ivan Pozdeev report at bugs.python.org
Thu May 3 22:34:40 EDT 2018


Ivan Pozdeev <ivan_pozdeev at mail.ru> added the comment:

Attached a fixed script.

`Tk.after()` works from a worker thread, while `Tk.destroy()` doesn't.

That's because Tkinter implements Tcl calls (_tkinter.c:Tkapp_Call) from another thread by posting an event to the interpreter's queue (Tcl_ThreadQueueEvent) and waiting for result. So a call normally works, but would hang if the interpreter's event loop is not running.

`destroy()`'s Python part (Lib\tkinter\__init__.py:2055) stops the event loop, then makes more Tcl calls -- which hang for the aforementioned reason if made from another thread.

----------
Added file: https://bugs.python.org/file47570/TkinterHanders32.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33412>
_______________________________________


More information about the Python-bugs-list mailing list