This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Ctrl-C does not terminate GTK3 Gtk.main() loop when program run from command line
Type: behavior Stage: resolved
Components: None Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Narnie.Harshoe, neologix
Priority: normal Keywords:

Created on 2012-02-27 03:13 by Narnie.Harshoe, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg154427 - (view) Author: Narnie Harshoe (Narnie.Harshoe) Date: 2012-02-27 03:13
In a normal python program, Ctrl-C will set up a KeyboardInterrupt and terminate the program. This works with a normal python script, including GTK2 gtk.main(), but GTK3 Gtk.main() (even when used in a more robust GTK program that coded below) will not terminate with Ctrl-C requiring a Ctrl-Z and killing the job to terminate. See the commmand line output below:

$ python -c "while True:
>  pass
> "
^CTraceback (most recent call last):
  File "<string>", line 1, in <module>
KeyboardInterrupt


$ python -c "import gtk
> gtk.main()
> "
^CTraceback (most recent call last):
  File "<string>", line 2, in <module>
KeyboardInterrupt


$ python -c "from gi.repository import Gtk
> Gtk.main()
> "
^C
^C
^Z
[1]+  Stopped                 python -c "from gi.repository import Gtk
Gtk.main()
"
$ kill %1

[1]+  Stopped                 python -c "from gi.repository import Gtk
Gtk.main()
"

The behaviour under Gtk.main() should be changed to respond to the KeyboardInterrupt.
msg154437 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2012-02-27 07:52
> The behaviour under Gtk.main() should be changed to respond to the 
> KeyboardInterrupt.

Well, you should report that to (Py)GTK folks then :-)
Either they set up a SIGINT handler, or they catch the KeyboardInterrupt exception, but that's not a problem with Python.
Closing.
msg154519 - (view) Author: Narnie Harshoe (Narnie.Harshoe) Date: 2012-02-27 23:50
Understood. I didn't realize it was 3rd party.
History
Date User Action Args
2022-04-11 14:57:27adminsetgithub: 58346
2012-02-27 23:50:21Narnie.Harshoesetmessages: + msg154519
2012-02-27 07:52:49neologixsetstatus: open -> closed

type: behavior

nosy: + neologix
messages: + msg154437
resolution: not a bug
stage: resolved
2012-02-27 03:13:27Narnie.Harshoecreate