Message206748
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. |
|
Date |
User |
Action |
Args |
2013-12-21 14:45:04 | vstinner | set | recipients:
+ vstinner, barry, pitrou, fossilet, eric.araujo, r.david.murray, neologix, Jurko.Gospodnetić, eric.snow, poq, telmich |
2013-12-21 14:45:04 | vstinner | set | messageid: <1387637104.61.0.19761487469.issue14228@psf.upfronthosting.co.za> |
2013-12-21 14:45:04 | vstinner | link | issue14228 messages |
2013-12-21 14:45:03 | vstinner | create | |
|