E. Paine <paineeli...@gmail.com> added the comment:
My initial thoughts were just to give the standard lecture on why "tkinter + threads = bad". However, looking again at the problem, the async handler error causes the Python interpreter to crash, which, no matter how frowned upon the code is, shouldn't happen. Ultimately, the issue is that a Tkapp object is being deleted in any thread other than the one it was created in. I believe there are two parts to the solution, both of which are for the Tkapp object in the _tkinter module (as there is no guarantee that the user will go through the standard tkinter module): 1. If a Tkapp object is created in a thread other than the main and it is made global, it is deleted in the main thread as part of the interpreter finalisation, not when the thread is finalising. I propose that the Tkapp object can only be created in the main thread, helping with part 2. 2. The Tkapp object 'refuses' to delete in a thread other than main, and instead gets collected on interpreter finalisation if needed (in the main thread). I don't know how to implement this, but if someone has some ideas, I am more than willing to help solidify them into a PR. Antoine, I hope you are the right person to add to the nosy for this (apologies if not). ---------- nosy: +epaine, pitrou versions: +Python 3.10, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39093> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com