After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 663068 - pygmainloop: avoid lockups if multiple glib.MainLoop exist
pygmainloop: avoid lockups if multiple glib.MainLoop exist
Status: RESOLVED FIXED
Product: pygobject
Classification: Bindings
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2011-10-30 22:15 UTC by Owen Taylor
Modified: 2012-04-03 20:28 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
pygmainloop: avoid lockups if multiple glib.MainLoop exist (1.26 KB, patch)
2011-10-30 22:15 UTC, Owen Taylor
committed Details | Review
Test case (686 bytes, text/plain)
2011-10-30 22:15 UTC, Owen Taylor
  Details

Description Owen Taylor 2011-10-30 22:15:09 UTC
This patch fixes a problem that occurs if multiple glib.MainLoop objects
exist. I'm not sure this is the be-all-and-end-all of trying to sort
out the interaction (and the interaction with the GTK+ main loop), but
it definitely makes things better for the case here where a signal
is ignored at the Python level.

The same problem occurs for pygobject2 and a trivial backport works.

I'll attach a test case.
Comment 1 Owen Taylor 2011-10-30 22:15:11 UTC
Created attachment 200304 [details] [review]
pygmainloop: avoid lockups if multiple glib.MainLoop exist

If multiple glib.MainLoop() sources exist, then we will add multiple
watches, and when python writes a byte to the wakeup pipe, all of the
sources will try to read it; only one will succeed and the others
will block. Set both ends of the pipe nonblocking to avoid this.
Comment 2 Owen Taylor 2011-10-30 22:15:38 UTC
Created attachment 200305 [details]
Test case
Comment 3 johnp 2011-11-01 15:58:36 UTC
This still doesn't work with Gtk.main()

Not sure if this is a similar bug but when using Gtk.main and sending a SIGINT (ctrl-c) the app hangs.  But if we use GLib.MainLoop().run() SIGINT does get caught and the app exits.

We can't link to Gtk so we can't override Gtk.Main() to provide signal handing.  Is there something similar we can do to fix that issue?
Comment 4 Tomeu Vizoso 2012-01-24 15:21:12 UTC
Comment on attachment 200304 [details] [review]
pygmainloop: avoid lockups if multiple glib.MainLoop exist

Could someone merge the test case into the test suite? Ideally there would be a single patch. Thanks!
Comment 5 Martin Pitt 2012-04-03 19:36:10 UTC
Comment on attachment 200304 [details] [review]
pygmainloop: avoid lockups if multiple glib.MainLoop exist

This was already committed in October 2011.
Comment 6 Martin Pitt 2012-04-03 20:28:43 UTC
I simplified your test case so that it avoids using ctypes and integrated it into the test suite:

http://git.gnome.org/browse/pygobject/commit/?id=2a5a33a9c9c170830c98c2e32fa8dcea3c35f2e6

Thank you!