[Python-Dev] Signals+Threads (PyGTK waking up 10x/sec).

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Dec 9 00:27:50 CET 2007


Guido van Rossum wrote:

> Does Unix even promise that a signal gets delivered twice if it gets
> sent quickly twice in a row?

No, it doesn't.

However, this doesn't necessarily mean that you can just
drop them when the pipe becomes full. If more than one
type of signal is sharing a pipe, you don't want it
getting filled up with signals of one type and causing
signals of a different type to get lost.

To guarantee that won't happen, you would have to either
use a separate pipe for each signal type, or have some
other scheme such as a bitmask keeping track of which
signal types are in the pipe.

> I have a worry though -- if signal handlers *always* and *only*
> communicate by writing a byte to a FD, does that mean that the VM main
> loop will have to attempt to read a byte from a pipe every time it
> checks for signals?

That sounds like a good reason for having the fd be an
additional mechanism that you can turn on when you want
it, but not the core mechanism for dealing with signals.

--
Greg


More information about the Python-Dev mailing list