Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
Using matploy throught pyplot when I quit my application I've the message :
Exception ignored in: <function Image.__del__ at 0x7fb34d3e4268>Traceback (most recent call last): File "/usr/lib/python3.7/tkinter/__init__.py", line 3504, in __del__RuntimeError: main thread is not in main loopTcl_AsyncDelete: async handler deleted by the wrong threadAbandon
I do the stuff into a separate thread because I want my primary thread to be responsive, no gui etc... I have only the default created figure and I've tryed to call plt.close() close('all') before the thread terminate.
It seems there is a static method in _backend_tk.py wich manage the mainloop, I've not followed all the code, but it seems it try to cleanup the rest at program exit.
Is there a way to make Tk and Tcl fully destroyed into my GUI thread ?
import timeimport threadingimport matplotlib.pyplot as pltclass MyThread(threading.Thread):def __init__(self):super().__init__()def run(self):plt.ion()while self._running:fig = plt.gcf()fig.clear()plt.show(block=False)plt.pause(0.1)plt.ioff()plt.close('all')my_thread = MyThread()my_thread.setDaemon(True)my_thread._running = Truemy_thread.start()time.sleep(2)my_thread._running = Falsemy_thread.join()