Joining threads but allowing signals to main thread?

Gabriel Genellina gagsl-py at yahoo.com.ar
Thu Jan 11 02:16:23 EST 2007


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)


-- 
Gabriel Genellina
Softlab SRL 


	

	
		
__________________________________________________ 
Preguntá. Respondé. Descubrí. 
Todo lo que querías saber, y lo que ni imaginabas, 
está en Yahoo! Respuestas (Beta). 
¡Probalo ya! 
http://www.yahoo.com.ar/respuestas 




More information about the Python-list mailing list