[Python-Dev] Re: Signal-resistant code (was: Two random and nearly unrelated ideas)

Zack Weinberg zack@codesourcery.com
Fri, 6 Sep 2002 10:28:03 -0700

On Fri, Sep 06, 2002 at 07:54:49PM +0300, Oren Tirosh wrote:
> Signal handlers and locks don't mix well. A signal handler can't grab a
> lock. The signal handler can't wait for the lock to be released because
> it has interrupted the code holding it. The traditional way this has been
> handled is with a global "interrupt enable" flag.  Just like the good old
> days of 8 bit micros and DOS when any application could clear the
> interrupt flag :-)
> If Queue.Queue sets up a signal critical section as well as getting the
> queue lock a signal could write to a Queue and wake up a thread waiting
> on the other end.

Would this be an appropriate place to complain about how
KeyboardInterrupt won't wake up a thread stuck waiting on a Queue?