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.

Author vstinner
Recipients Jurko.Gospodnetić, barry, eric.araujo, eric.snow, fossilet, neologix, pitrou, poq, r.david.murray, telmich, vstinner
Date 2013-12-21.14:45:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1387637104.61.0.19761487469.issue14228@psf.upfronthosting.co.za>
In-reply-to
Content
Sorry, but I don't understand this issue. Well, I understood the issue as "When I press CTRL+c to interrupt Python, Python does exit". What's wrong with that? Why do you send CTRL+c if you don't want Python to exit?

Using custom signal handler (SIG_IGN), it would be possible to ignore SIGINT during Python initialization. Using pthread_sigmask(), it is possible to defer the handling of the signal until user is able to setup its own custom signal handler (or just use try/except KeyboardInterrupt). But I don't like these options. I would like to be able to kill (stop) Python as early as possible with CTRL+c.

If you are only worried by the long traceback when importing the site module is interrupted, you can use -S. On UNIX, you can then use signal.pthread_sigmask() to defer the handling of SIGINT.

The whole issue remembers me the dummy question: "is the finally block executed even if I unplug the power cable?".

> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652926

This issue can be solved using python -S, calling signal.signal(SIGINT, signal.SIG_DFL) and then import the site module manually.
History
Date User Action Args
2013-12-21 14:45:04vstinnersetrecipients: + vstinner, barry, pitrou, fossilet, eric.araujo, r.david.murray, neologix, Jurko.Gospodnetić, eric.snow, poq, telmich
2013-12-21 14:45:04vstinnersetmessageid: <1387637104.61.0.19761487469.issue14228@psf.upfronthosting.co.za>
2013-12-21 14:45:04vstinnerlinkissue14228 messages
2013-12-21 14:45:03vstinnercreate