Joining threads but allowing signals to main thread?

Lloyd Zusman ljz at asfast.com
Thu Jan 11 05:48:47 EST 2007


Gabriel Genellina <gagsl-py at yahoo.com.ar> writes:

> At Thursday 11/1/2007 03:43, Lloyd Zusman wrote:
>
>>   while threading.activeCount() > 1:
>>       time.sleep(0.001)
>>
>>   sys.exit(0)
>>
>>Is there any way to allow my program to respond to signals without
>>having to busy-wait in the main thread?
>
> Don't worry too much, this is *not* a busy wait, because you use
> sleep. You can use a longer sleep, it will be terminated by any
> signal. But not too long, or the check for activeCount() will be delayed
> in excess. (I use sleep(1) usually but your needs may be different)

Well, if this is the best that we can currently do in python, then so be
it.

My sincere thanks.


-- 
 Lloyd Zusman
 ljz at asfast.com
 God bless you.




More information about the Python-list mailing list