threading ignora a exceção KeyboardInterrupt
Estou executando este código simples:
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')
Mas quando eu corro, ele imprime
$ python prova.py
.
.
^C.
.
.
.
.
.
.
.
Exception KeyboardInterrupt in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
De fato, o segmento python ignora meuCtrl+C interrupção do teclado e não imprimeReceived Keyboard Interrupt
. Por quê? O que está errado neste código?