el enhebrado ignora la excepción KeyboardInterrupt
Estoy ejecutando este código simple:
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')
Pero cuando lo ejecuto, imprime
$ python prova.py
.
.
^C.
.
.
.
.
.
.
.
Exception KeyboardInterrupt in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
De hecho, el hilo de Python ignora miCtrl+C interrupción del teclado y no imprimeReceived Keyboard Interrupt
. ¿Por qué? ¿Qué está mal con este código?