[pygtk] PyGTK, threads and accessibility - application hangs
pygtk-mailinglist at wodny.org
Thu Aug 11 03:35:48 WST 2011
I've created some applications using PyGTK and thought they had been
OK until I executed them in an environment with accessibility
enabled (GNOME on Ubuntu and Openbox on Debian). I've found out they
hang and what is more frustrating - they cause AT-SPI applications
I've created a repo with all variants of using PyGTK with
threads I could think of:
- primarythread prefix means gtk.main() works inside the primary
thread (one executed first by Python)
- secondarythread prefix means gtk.main() works inside the secondary
- gobject suffix means only gobject.threads_init() has been used,
- gtkgdk suffix means both gobject and gtk.gdk.threads_init() have
- import suffix means "import gtk" is executed inside the new thread.
showApps.py is an example of an application using AT-SPI to list
applications with accessibility enabled.
I've summarized tests in the table below (also inside the README
"Hang" column indicates if the GTK application has hung.
"Listed" column indicates if the application is visible in the AT-SPI
| hang | listed |
primarythread_gobject.py | no | yes |
primarythread_gtkgdk.py | no | yes |
secondarythread_gobject_import.py | no  | yes |
secondarythread_gobject.py | yes | hang |
secondarythread_gtkgdk_import.py | no  | yes |
secondarythread_gtkgdk.py | yes | hang |
 ** (secondarythread_gobject_import.py:5828): CRITICAL **:
giop_thread_request_push: assertion `tdata != NULL' failed
-- at the application termination
When AT-SPI is marked "hang" it hangs unconditionally during
Hanging of the PyGTK application happens for example after losing and
regaining focus by its window.
Test showed that no problems occur when gtk.main() is run from the
first/main Python thread. But this doesn't satisfy me as I don't like
treating GUI as the main part of the application.
My questions are:
1. Is there anything wrong with code in programs marked as
secondarythread? Or is it a bug in GTK/GAIL/AT-SPI?
2. Is there a policy that prohibits running gtk.main() outside the
first/main Python thread?
I've asked the same questions at the StackOverflow.
I've also seen a very similar post at this mailing list. But as a
response only a suggestion to use gtk.gdk.threads_init() has been made.
I've used that one already.
Marcin Szewczyk http://wodny.org
mailto:Marcin.Szewczyk at wodny.borg <- remove b / usuń b
xmpp:wodny at ubuntu.pl xmpp:wodny at jabster.pl
More information about the pygtk