threading ignoriert die KeyboardInterrupt-Ausnahme
Ich führe diesen einfachen Code aus:
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')
Aber wenn ich es starte, druckt es
$ python prova.py
.
.
^C.
.
.
.
.
.
.
.
Exception KeyboardInterrupt in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
In der Tat Python-Thread ignorieren meine Strg+C Tastatur unterbrechen und druckt nichtReceived Keyboard Interrupt
. Warum? Was ist los mit diesem Code?