Tag: keyboardinterrupt

线程忽略KeyboardInterruptexception

我正在运行这个简单的代码: 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 […]