Is a running thread eligable for garbage collection if the thread object is reasigned? For example:
class A(threading.Thread)
def run():
while True:
#Do stuff
a = A()
a.start()
time.sleep(60)
a = A()
at this point, even though thread A is still doing stuff, can the interpreter destroy the original A() thread? If it does, is there a way to prevent this from happening?
My guess is no. There’s still a reference to the thread in whatever structure Python uses to keep track of things. I’ll test it out, but I’d be astonished if it didn’t work.
EDIT Check it out: