Garbage collector and threads

Nicolas Fleury nid_oizo at yahoo.com_remove_the_
Mon Mar 1 17:10:59 CET 2004

Hi everyone,
	I just discovered, correct me if I'm wrong, that as long as a 
threading.Thread is running, its destructor will not be called, because 
it is referring to himself.  So if I have something like:

class MyThread(threading.Thread):
     def __init__(self):
         self.cancelEvent = threading.Event()
     def __del__(self):
     def run(self):
     def cancel(self):

I must call cancel from the outside if I want the destructor to be 
called (note that I don't want deamon threads).  I can make a wrapper 
over threading.Thread to have the behaviour I want: have a thread with 
__del__ called when it is not referred by another thread.  But my 
question is, and I don't have an overall vision of the issue at all, 
should that be the default behaviour anyway?


More information about the Python-list mailing list