我有一个我认为是简单的线程设置:产生一个守护子线程,然后等待键盘输入停止:
MASTER = threading.Thread(target=QueueMonitor())
MASTER.setDaemon(True)
MASTER.start()
while True:
ZZ = raw_input("running...\ntype 'ZZ' to quit \n\n")
if 'ZZ' in ZZ:
print "1. cleaning up... (this can take some time)"
KILLALL = 1
sys.exit()
子线程在等待键盘输入杀死所有内容时每'x'秒循环并打印输出。代码永远不会返回到“ZZ”输入,但似乎坚持在子线程上:
thread: 1
thread: 2
thread: 3
thread: 4
thread: 5
thread: 6
thread: 7
thread: ...
我究竟做错了什么?