STINNER Victor added the comment:

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.

----------
nosy: +haypo

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue14228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to