[python-win32] Detecting Ctrl-Break

Gabriel Genellina gagenellina@softlab.com.ar
Mon, 20 May 2002 22:11:47 -0300


Hi

How can I detect Ctrl-Break?
Ctrl-C raises KeyboardInterrupt, but Ctrl-Break does not. Apparently it 
aborts the interpreter, even the try/finally block isn't honored.

Test:

import sys

def test():
     while 1:
         print '.',

if __name__=='__main__':
     try:
         try:
             test()
         except KeyboardInterrupt:
             print "\nKeyboardInterrupt detected"
             sys.exit(0)
         except:
             print "\nAnother exception"
             sys.exit(0)
     finally:
         print "\nFinally"


Gabriel Genellina
Softlab SRL