GNOME Bugzilla – Bug 96018
Make Ctrl-C raise KeyboardInterrupt in pygtk programs
Last modified: 2004-12-22 21:47:04 UTC
Currently all pygtk programs ignore Contrl-C. I guess this is because when gtk.main(loop) is being called the python interpretor is left aside without a chance to breath. Is it enough to add a function that's called every, say 100ms that allows the interpretor to think a bit (PyAddPendingCalls or something).
Created attachment 11647 [details] [review] v1: Create a timeout function in _wrap_gtk_main() which is called every 100ms
I benchmarked Py_MakePendingCalls a bit, and it takes more or less no cpu time at all. So i don't think 100ms is too often. Maybe we could lower it a bit to get more responsive Ctrl-C. But it's not a too big deal.
Created attachment 11734 [details] [review] v2: Don't call gtk_main_quit, don't return FALSE. remove the handler after gtk_main
this is a dup of bug 72333 but I won't mark it as such, as it has a patch. As discussed on IRC, there are a few problems with the patch: - sets up a new timeout every time gtk.main() is called (causes multiple timeouts to fire in recursive main loops). - uses gtk_signal_remove() to dequeue the timeout - should be calling PyErr_CheckSignals() instead of Py_MakePendingCalls(). (apparently Py_MakePendingCalls() is set to be deprecated).
Closing. Will attach new patch on bug 72333 shortly *** This bug has been marked as a duplicate of 72333 ***