потоки игнорируют исключение KeyboardInterrupt
Я запускаю этот простой код:
import threading, time
class reqthread(threading.Thread):
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
, Зачем? Что не так с этим кодом?