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

Ivan Pozdeev report at bugs.python.org
Thu May 3 21:09:30 EDT 2018


Ivan Pozdeev <ivan_pozdeev at mail.ru> 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 posting an event.


> The only problem is that the first t.join() hangs because of a thread deadlock bug.  t.join() blocks until t.run exits.  t.run does not exit until the last event_generate, with running=False, returns.  But that blocks until dummy_handler runs.
> I suppose there is a teeny possibility that 'running' could be flipped between the test and the call.  Can that be prevented with a lock?

The idea is to let the worker threads finish their work, not terminate them forcibly.
So the real problem is that stop() blocks the event loop.
It should rather run asynchronously, wait for threads, then trigger `self.root.destroy()` in the main thread... somehow.

----------
resolution: wont fix -> not a bug

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


More information about the Python-bugs-list mailing list