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 to hang.
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 thread,
multiprocessing prefix means import and gtk.main() are executed in another process.
gobject suffix means only gobject.threads_init() has been used,
- gtkgdk suffix means both gobject and gtk.gdk.threads_init() have been used,
- 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 file):
"Hang" column indicates if the GTK application has hung.
"Listed" column indicates if the application is visible in the AT-SPI
listing.
| hang | listed |
----------------------------------+----------+--------+
primarythread_gobject.py | no | yes |
primarythread_gtkgdk.py | no | yes |
secondarythread_gobject_import.py | no [1] | yes |
secondarythread_gobject.py | yes | hang |
secondarythread_gtkgdk_import.py | no [1] | yes |
secondarythread_gtkgdk.py | yes | hang |
multiprocessing_gobject.py | no | yes |
[1] ** (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 applications listing.
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:
- Is there anything wrong with code in programs marked as secondarythread? Or is it a bug in GTK/GAIL/AT-SPI?
- Is there a policy that prohibits running gtk.main() outside the first/main Python thread?