[Tutor] Waiting until a thread ends

lists lists at justuber.com
Sun Mar 20 00:36:54 CET 2011


>
>
>
>> In my continuing quest the find the best way of doing this I came across
>> the following method:
>>
>>     for thread in threading.enumerate():
>>         if thread is not threading.currentThread():
>>             thread.join()
>>     print 'FINISHED'
>>
>> In my newbie understanding, you can't join() the current thread, because
>> it's the main thread (the one from which the others are called), join()ing
>> it would lock the program up (it would never complete).
>>
>> The above only join()s a thread if it isn't the current thread, thus
>> (hopefully) getting around this. Swapping my earlier stupid code for this
>> seems to work as expected in my tests.
>>
>
> Thanks for the postbacks, it's been useful/interesting for me.
>
> Best,
>
> Walter
>

I'm really pleased that it was of some help to somebody else too.

Kind Regards,

Chris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110319/64acc5dd/attachment.html>


More information about the Tutor mailing list