【发布时间】:2016-07-26 17:11:27
【问题描述】:
import threading
import time
def worker(i):
while True:
try:
print i
time.sleep(10)
break
except Exception, msg:
print msg
threads = []
for i in range(10):
t1 = threading.Thread(target=worker, args=(i,))
threads.append(t1)
for t in threads:
t.start()
print "started all threads... waiting to be finished"
for t in threads:
t.join()
如果我在线程运行时按 ^C,线程会获得 SIGINT 吗?
如果这是真的,我可以从调用者线程做些什么来阻止它传播 SIGINT 到正在运行的线程?
调用者线程中的信号处理程序会阻止它吗?
还是我需要每个线程的信号处理程序?
【问题讨论】:
标签: python multithreading signals