multithreading - killing Finished threads in python -
my multi-threading script raising error :
thread.error : can't start new thread
when reached 460 threads :
threading.active_count() = 460
i assume old threads keeps stack up, since script didn't kill them. code:
import threading import queue import time import os import csv def main(worker): #do work print worker return def threader(): while true: worker = q.get() main(worker) q.task_done() def main_threader(workers): global q global city q = queue.queue() x in range(20): t = threading.thread(target=threader) t.daemon = true print "\n\nthreading.active_count() = " + str(threading.active_count()) + "\n\n" t.start() worker in workers: q.put(worker) q.join()
how kill old threads when job done? (is return not enough?)
i'm sure old threads work done i'm printing results , i'm not sure why still active afterward , direct way kill thread after finish work ?
Comments
Post a Comment