Garbage collector and threads

Nicolas Fleury nid_oizo at yahoo.com_remove_the_
Mon Mar 1 11:36:19 EST 2004


Aahz wrote:
> Yes, Don't Do That.  Do not rely on finalizers for external resources
> (such as threads).

Why?  Isn't a kind of RAII applied to Python?

> Note that your understanding of Python's memory management could use some
> improvement: GC *never* runs on objects containing __del__

Well, I guess you're right.  What I mean is the reasons behind the call 
to __del__, whatever it is ref-counting or something else.  Wouldn't a 
class like CancellableThread, with a sub-class implemented cancel method 
called when the object is not referred in any other thread be useful?

Regards,
Nicolas



More information about the Python-list mailing list