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

2018-05-06 Thread Ivan Pozdeev
Ivan Pozdeev added the comment: > Without thread support, event generation from multiple threads fails > immediately. This ticket is for threaded Tcl only, so this is off topic. In nonthreaded Tcl, this script crashes rather than freezes, for an entire ly different reason that I already expl

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

2018-05-06 Thread Terry J. Reedy
Terry J. Reedy added the comment: Without thread support, event generation from multiple threads fails immediately. I tried an experiment with callback scheduling. It seems to work -- almost. thread_event.py runs on 2.7 with non-t tcl. It modifies TkinterHandlres32.py by replacing

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

2018-05-05 Thread Terry J. Reedy
Terry J. Reedy added the comment: When I closed the main thread by clicking [x], thus destroying root, both event threads raised instead of hanging. So my experiment involved calling root.destroy instead of setting running to False. The better result when running under IDLE might be due to

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

2018-05-03 Thread Guido van Rossum
Change by Guido van Rossum : -- nosy: -gvanrossum ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mai

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

2018-05-03 Thread Ivan Pozdeev
Ivan Pozdeev 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 wa

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

2018-05-03 Thread Ivan Pozdeev
Ivan Pozdeev added the comment: > Another possibility is for stop() to change conditions so that > 'self.target.event_generate(c)' fails with an exception Could you elaborate? Since there're no docs on event_generate(), I can't look up how to make it "fail with an exception" without actually

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

2018-05-03 Thread Terry J. Reedy
Terry J. Reedy added the comment: >From 1994 to 2017, _tkinter.c has received a steady flow of multiple revisions >each year, for 333 total, by maybe 20 people including Guido. This makes it >one of the more actively maintained files and indicates the opposite of >indifference and not caring

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

2018-05-02 Thread Guido van Rossum
Guido van Rossum added the comment: I guess nobody gives a damn. -- resolution: -> wont fix stage: -> resolved status: open -> closed ___ Python tracker ___ _

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

2018-05-02 Thread Ivan Pozdeev
Ivan Pozdeev added the comment: > Do you have a suggestion for what to do short of dropping Tkinter support? Didn't really look into this. At first glance, from the trace log, the main thread seems to grab a lock at some initial point, and then tries to grab it again when running an event ha

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

2018-05-02 Thread Guido van Rossum
Guido van Rossum added the comment: So it seems threads and Tkinter events don't mix. This doesn't surprise me much. (Similar issues can occur when mixing threads and asyncio if you don't follow the documentation's advice about how to send events across threads.) Perhaps event_generate() need

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

2018-05-02 Thread Ivan Pozdeev
Ivan Pozdeev added the comment: > worker threads are waiting for the Tcl lock Pardon. They are waiting for Tkapp_ThreadSend()s into the main thread to return. The effect is still the same. -- ___ Python tracker

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

2018-05-02 Thread Ivan Pozdeev
Change by Ivan Pozdeev : Added file: https://bugs.python.org/file47564/trace.py ___ Python tracker ___ ___ Python-bugs-list mailing list Unsu

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

2018-05-02 Thread Ivan Pozdeev
New submission from Ivan Pozdeev : With threaded Tkinter, TkinterHanders3.py from https://bugs.python.org/issue33257 (attached) hangs. Tracing with thread_debug and a modified trace.py (to show TIDs, attached) shows that worker threads are waiting for the Tcl lock while the main thread that h

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

2018-05-02 Thread Ivan Pozdeev
Change by Ivan Pozdeev : Added file: https://bugs.python.org/file47563/trace.zip ___ Python tracker ___ ___ Python-bugs-list mailing list Uns