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

Guido van Rossum guido at python.org
Tue Dec 11 00:26:09 CET 2007

> Adam & I are now on #python-dev. Can you join?

I think we successfully resolved this. Adam Olsen will produce a patch
that allows one to specify a single file descriptor to which a zero
byte will be written by the C-level signal handler. Twisted and PyGTK
will have to coordinate about this file descriptor. Glyph believes
this is possible and sufficient.

(A preliminary version of the patch may be found here:
http://dpaste.com/27576/ )

We considered two alternatives:

(a) A patch by myself where the file descriptor would instead be
passed together with a signal handler. This was eventually rejected
because it places an extra burden on every piece of code that
registers a signal handler.

(b) A more elaborate patch by Adam which would allow many file
descriptors to be registered. This was rejected for being more code
and solving a problem that most likely doesn't exist (multiple
independent main loops running in different threads).

We also located the exact source of the 100 msec timeout in PyGTK:


line 1075: *timeout = 100;

The recommendation for the OLPC XO project is to remove this line or
make the timeout much larger, as the only reason why this was even
added to PyGTK is wanting a fast response to ^C from the console,
which doesn't represent a viable use case on the XO.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-Dev mailing list