drothlis/stb-tester — pull request #162 by wmanley (2014-05-22 22:58:18+00:00)
Title: stbt.py: Fix Ctrl-C ignored since port to GStreamer 1.0

When the GLib mainloop is constructed through [the default Python
constructor it adds a signal watch on SIGINT][1]. This is a [python
override][^2] ostensibly to "Retain classic pygobject behaviour of quitting
main loops on SIGINT". This commit uses the non-override MainLoop
constructor which is more conservative and doesn't add a signal watch.

This change is not without side-effects. The adding of the signal watch
was causing GLib to create another thread called "gmain". In my
experiments it seems that our own `_mainloop` wasn't being used (or at
least wasn't necessary) at all. After this change the "gmain" thread is
no longer created and callbacks are running on our `_mainloop` as expected
from reading the code.

This commit exposes (or at least highlights) that the mainloop code isn't
quite right. In my tests I get the message "teardown: Source pipeline did
not teardown gracefully" whether I Ctrl-C or not. This behaviour is,
however, present before this commit, so is not a regression caused by this
commit.

Fixes #138.

[^2]: The new GObject Python bindings are automatically generated from the
C sources, and so method calls should behave identically to if they
were made from C. Overrides are where there is additional code added
to the bindings for a particular language - in this case Python.

[1]: https://git.gnome.org/browse/pygobject/tree/gi/overrides/GLib.py?id=3.10.1#n513