global exception catching

Rene Pijlman reageer.in at de.nieuwsgroep
Thu Feb 27 04:45:44 EST 2003


Duncan Booth:
>be aware that neither of these will properly handle Ctrl-Break on Windows. 
>If you need to handle Ctrl-Break then (provided you are using Python 2.2 
>or later) you have to install a SIGBREAK handler. e.g. 
>
>    signal.signal(signal.SIGBREAK, signal.default_int_handler)
>
>This would make Ctrl-Break raise KeyboardInterrupt instead of its default 
>action which is to terminate your Python program without doing any cleanup.
>If your application does anything with network sockets then these will 
>interact badly with a SIGBREAK handler (you might need multi-threading to 
>handle this effectively).

Brrr... Wouldn't it be better to simply remove the Break key
from the keyboard? :-)

-- 
René Pijlman

Wat wil jij leren?  http://www.leren.nl




More information about the Python-list mailing list