How to wait for a list of threads to finish? (Python)
For a single thread, I would do
thread.join(60)
threadEvent.set()
How can I make it wait for all threads in the list to开发者_如何转开发 finish OR wait until the timeout and then issue the set() to the threading.Event()? Each thread has a corresponding threading.Event() that will be used to stop the thread. The important part is that if the timeout is reached, I need to set the event for each thread.
import time
endTime = time.time() + 60
for t in threads:
t.join(endTime - time.time())
t.event.set()
精彩评论