KeyboardInterrupt not caught
Daniel Nogradi
nogradi at gmail.com
Fri Feb 16 04:58:54 EST 2007
> why is KeyboardInterrupt not caught (xp)?
> import sys
> try:
> inp = sys.stdin.read()
> except (KeyboardInterrupt, SystemExit):
> print "kbd-interr,SystemExit"
> except EOFError:
> print "eof encountered"
> except:
> print "caught all"
> self.showtraceback()
> print "normal end"
>
> result after script startet and ^C hit:
> >ctrl_test.py
> normal end
> Traceback (most recent call last):
> File "C:\work\py_src\ctrl_test.py", line 11, in ?
> print "normal end"
> KeyboardInterrupt
Hi, are you sure this is exactly what you run?
The code above works perfectly for me and prints
kbd-interr,SystemExit
normal end
as it should upon pressing Ctrl-C (although I'm on linux not xp but
that shouldn't matter at all).
More information about the Python-list
mailing list