Garbage collector and threads

Aahz aahz at pythoncraft.com
Mon Mar 1 18:07:32 CET 2004


In article <1EJ0c.4334$mx4.105438 at nnrp1.uunet.ca>,
Nicolas Fleury  <nid_oizo at yahoo.com_remove_the_> wrote:
>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?

What's "RAII"?

>> 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?

Perhaps, but threading needs references to created threads in order to
implement its functionality.  You might try building your own thread
constructs using ``thread`` directly.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"Do not taunt happy fun for loops. Do not change lists you are looping over."
--Remco Gerlich, comp.lang.python



More information about the Python-list mailing list