On Feb 29, 2:12 pm, [EMAIL PROTECTED] wrote:
> If a thread adds an object it creates to a nonlocal
> collection, such as a class-static set, does it have to maintain a
> list of all such objects, just to get the right ones destroyed on
> completion?  
Yes.

> Processes destroy their garbage hassle-free; how can
> threads?  

If you're asking "is there some automatic way to associate a external
resource with a thread so that it's deleted when the thread is done"
then the answer (to the best of my knowledge) is no.  You would have
to take care of these details yourself once something outside your
thread got a reference to the resource. If you keep all references to
the resource inside the thread, then you can use the __del__ method of
the resource to take any cleanup actions.

Also, processes don't always "destroy their garbage hassle free" if
you consider inter process communication.  For instance, if you create
an object in one process then serialize it and pass it to another
process through e.g. an XMLRPC call, there's no automatic way for the
other process to be notified that the originating process exited.
You'd have to build that feature in.  Exact same thing with threads.

> And don't forget Thread.run( self ) in the example, if
> anyone ever wants to make use of the 'target' keyword.

I don't understand what you're referring to.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to