Is it bad in Python, when I don’t hold a reference of a Thread I created with: threading.Thread(target=worker_method)? Is it possible that the garbage collecor does anything to it, which affects the stability of my application?
Is it bad in Python, when I don’t hold a reference of a Thread
Share
The thread will keep running regardless, but the downside is that you don’t have a handle to the thread any more in order to communicate with it.
A simple test shows that even when the thread object goes out of scope, its still running:
Even if you were to delete the
tthread object right after starting it, it will keep running. But you really should be keeping track of thread that you start, to make sure they finish or to monitor if they are alive. And also, to shut them down cleanly if need be.