Python multithreaded GTK programs are still polling in F9, F10
John Gilmore
gnu at toad.com
Sun Aug 10 00:46:56 EDT 2008
> The bug has been fixed! There's no need to avoid multi-tasking Python
> programs any more. It's fixed in python-2.6, PyGOboject 2.14.1, and
> PyGTK 2.12.1. See http://dev.laptop.org/ticket/4680#comment:12
>
> The [OLPC] 8.2.0 release candidates in Joyride already include those
> releases of PyGObject and PyGTK, and uses python-2.5 with the bug
> fix back-ported from python-2.6.
I spoke too soon. We have "fixes" in the Joyride releases, but they
were never tested, and they don't work yet. See:
http://dev.laptop.org/ticket/4678#comment:4
and
http://bugzilla.gnome.org/show_bug.cgi?id=481569
Every multi-threaded Python GTK program in OLPC (and F9, and
F10-Alpha) is still polling once a second. You can easily see this by
doing strace on the sugar-shell Python process.
The test in ./configure in pygobject2-2.15.1-2.fc10.src.rpm uses C to
look in /usr/include/Python.h for PySignal_SetWakeupFd(). There's no
such thing in the Python header files or executable, though. The patch in
python-2.5.1-25.fc9.src.rpm inserts a static function in
signalmodule.c, and adds it to the signal_methods table so that it's
visible from Python. (The changelog says "Resolves: rhbz#427794".)
But the changes are not visible from C. I also checked the F9 and F10-Alpha
binaries; they're compiled without this fix.
Aha! The "patch file" that F9 included is #4 from the Python bug
entry here:
http://bugs.python.org/issue1583
But one day later, upon request, Guido van Rossum added a simple C API
as well, patching Include/pyerrors.h and adding a ten-line public
PySignal_SetWakeupFd function to Modules/signalmodule.c. Those
changes were just made in SVN though; not in a patch file. Those
final changes, including the C API, mistakenly did not get patched
into Fedora's Python-2.5.1 (neither for F9 nor for F10-Alpha).
So one bug is in Fedora's Python-2.5.1; the patch file
python2.6-set_wakeup_fd4.patch needs to be updated to include Guido's
final version from:
http://svn.python.org/view?rev=59574&view=rev
The needed change in signalmodule.c is to add these 10 lines:
/* C API for the same, without all the error checking */
int
PySignal_SetWakeupFd(int fd)
{
int old_fd = wakeup_fd;
if (fd < 0)
fd = -1;
wakeup_fd = fd;
return old_fd;
}
plus two lines in Include/pyerrors.h:
/* In signalmodule.c */
int PySignal_SetWakeupFd(int fd);
There's apparently another bug in the gtk code that tries to use this
facility; Gnome bug 481569 referenced above gives a litany of
attempts to get this right, but it may not be there yet.
Soon, if the Python in F10 and/or OLPC is fixed, and its pygobject is
recompiled using that Python into a new binary package, and pygtk is
fixed properly, Python multithreaded programs will stop their needless
polling. We're getting very close...
John Gilmore
More information about the Devel
mailing list