Я запускаю этот простой код:
import threading, time
class reqthread ( threading.Thread ):
def __init__ (self):
threading.Thread.__init__(self)
def run ( self ):
for i in range(0,10):
time.sleep(1)
print '.'
try:
thread=reqthread()
thread.start()
except (KeyboardInterrupt, SystemExit):
print '\n! Received keyboard interrupt, quitting threads.\n'
Но когда я запускаю его, он печатает
$ python prova.py
`
.
.
^C.
.
.
.
.
.
.
.
Exception KeyboardInterrupt in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
`
Фактически поток python игнорирует мое прерывание клавиатуры Ctrl + C и не печатает Received Keyboard Interrupt
. Зачем? Что не так с этим кодом?