Sion Arrowsmith wrote: > In article <[EMAIL PROTECTED]>, Benjamin Niemann <[EMAIL PROTECTED]> > wrote: >>[EMAIL PROTECTED] wrote: >>> However, in my current project I'm creating a bunch of threads which >>> are supposed to run until they've completed their run() method, and I'm >>> worried that if I do not keep references to these thread objects >>> around, the GC might happily delete them (and thereby kill my thread >>> routines maybe?) while they're not done yet. Is this fear justified? >>The threading module does already take care of keeping references to all >>running threads, > > The implementation of threading.enumerate() would be entertaining if it > didn't. > > Quite apart from which, I presume the OP's run() method looks something > like: > class MyThread(threading.Thread): > def run(self): > ... > So what is self if not a reference to the Thread object which is kept > around until run() has completed?
This was just too obvious;) Looking at the sourcecode of the threading module and discovering the 'limbo' dict, where every thread stores a reference to itself, was certainly more entertaining. -- Benjamin Niemann Email: pink at odahoda dot de WWW: http://www.odahoda.de/ -- http://mail.python.org/mailman/listinfo/python-list