Exception RuntimeError: RuntimeError('main thread is not in main loop',)
See original GitHub issueIn the main program I call modules (five times). In each module I use joblib.Parallel in the same way. If I call only one of these modules from the main program, everything is doing great. If in the main program I choose the option to execute the five modules one by one, in the third of them I get the following error:
Exception RuntimeError: RuntimeError('main thread is not in main loop',) in <bound method PhotoImage.__del__ of <Tkinter.PhotoImage instance at 0x7f72ac673c68>> ignored
Tcl_AsyncDelete: async handler deleted by the wrong thread
Aborted
When only that third subprogram (module) is called, everything is executed without error. joblib-0.13.0, Debian
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
RuntimeError: main thread is not in main loop - python
From your traceback, it looks like you're running the workerGuiThread from a thread you're creating elsewhere, rather from the main thread of ...
Read more >[ Bug] RuntimeError: main thread is not in main loop (window ...
Finally I suspected that the issue could be related to an expired timeout from within TCL/TK. ... Tkapp_Call() calls WaitForMainloop() where there ...
Read more >“main thread is not in main loop” in Tkinter - Python Forum
I have paths of two GIF files in a list. After input (name of the planet) it just shows looped GIF in tkinter....
Read more >RuntimeError: main thread is not in main loop
Console shuts down after I 'import importlib' and here is the error it gives. >>> import importlib. Exception ignored in: <bound method ...
Read more >tkthread · PyPI
The Tcl/Tk language that comes with Python follows a different threading model ... RuntimeError: main thread is not in main loop RuntimeError: Calling...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
My diagnosis seems correct, I won’t need more, I just changed back and no longer open any
matplotlib
plots before being completely done with theParallel
-code. It’s not worth my time trying to find a better solution. Thanks again for your reply!Hi @tomMoral, thanks for the quick reply 👍!
I understood the bug (I think): if a first figure is created (but not manually deleted with
del fig
) before I run myParallel(...)(delayed(...))
code, then the garbage collector can decide (pseudo)randomly to delete the figure anytime, in one of the thread. This makes the code break, becausetkinter
doesn’t support multi-threaded code, as soon as this garbage collector delete does not happen in the main thread (which explain why the bug happened faster on my 4-core & 4-thread machine than on another 12-core & 12-thread machine).I’ll try again to verify if my diagnosis is correct. if it is, then I don’t think we can do anything:
tkinter
is known to not work in multi-threaded environment, andjoblib
can’t magically decide to preventively close allmatplotlib
figures before going intoParallel
-powered code! If my diagnosis is wrong, I’ll provide a minimal working example that can be launch in a virtualenv, so you can test the bug. Thanks!