-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gstreamer/PyGObject breaks SIGINT handling #63
Comments
Hmm; I don't think I quite understand. What do you mean by "the original behavior" here? Are you saying that GLib itself (or perhaps GStreamer, or perhaps PyGObject—not sure which) installs a SIGINT handler when it's loaded? If the latter, perhaps this bug is best addressed in one of those projects instead of audioread itself? |
Sorry, bad formulation. I edited it. PyGObject installs a SIGINT handler, and the main Python thread will never get a KeyboardInterrupt, which is not what you want. You can see that in the code. Actually, not in the upstream code on GitHub (here), but in the Ubuntu 16 version:
pip installing a new version also is somehow broken on Ubuntu. I didn't investigated this further. |
Ah, I see! So perhaps the right thing to do would be to add a Perhaps this SO answer points to a reasonable alternative? |
Yes, that would be another solution. You can use The SO solution is not so nice as it would just kill your Python program (I think) and not do the proper handling which you might want for KeyboardInterrupt. Actually, calling audioread should just not change the behavior of that in any way. E.g. consider that the user had installed an own custom handler, which would just get overwritten by this. |
fyi, pygobject 3.28+ will no longer install a signal handler there if one was already set before and will no longer change anything when not run in the main thread. There is an easier fix to work around all this: instead of |
Awesome, @lazka; thank you for the background. Do you happen to know where in the docs I can learn about the difference between the |
Sadly nowhere. |
Got it; thanks again for the background about how this happened! |
GLib.MainLoop.__init__
installs a SIGINT handler which callsGLib.MainLoop.quit()
,and then reraise a KeyboardInterrupt in that thread.
However, the main thread will not notice that, and continues whatever it is doing, which mostly means that it will hang as it is waiting for something.
What you would want is a KeyboardInterrupt in the main thread, as this is the original behavior when you press Ctrl+C.
I came up with this workaround / ugly monkey patch to just disable the SIGINT handler.
However, a better fix would be in PyGObject to raise the KeyboardInterrupt in the main thread.
The text was updated successfully, but these errors were encountered: