Using signal.alarm to terminate a thread

Fredrik Lundh fredrik at pythonware.com
Tue Nov 14 06:40:37 EST 2006


Nick Craig-Wood wrote:

>   The only sensible things you can do from a signal handler is set a
>   global flag, or call sem_post on a semaphore, to record the delivery
>   of the signal. The remainder of the program can then either poll the
>   global flag, or use sem_wait() and sem_trywait() on the semaphore.

but that's exactly what Python's signal handlers do, right ?

(the interpreter uses a "pending call" queue to collect events, and 
executes them from the interpreter main loop in a controlled fashion).

</F>




More information about the Python-list mailing list