Let's say I instantiate the following class in jupyter lab:
class my_class(object):
def __init__(self):
self.proc = multiprocessing.Process(...)
self.proc.start()
def __del__(self):
self.proc.terminate()
x = my_class()
In __init__(), a process is spawned that opens a PyQt5 window. I have confirmed that del x kills the spawned process, thereby closing the window.
When I restart the kernel of my jupyter lab-notebook, __del__() is not called and the window remains open. Can I teach jupyter lab to execute the destructors of all variables in all namespaces (or even just in global namespace), before the notebook kernel is restarted?