I'm using the multithreading module of python but the code doesn't work sometimes. I print the count of active threads and found that sometimes the started threads are not active. Here is the code:
def do_stuff(q,obj):
while not q.empty():
item=q.get()
print item
q.task_done()
for i in range(num_thread):
worker=threading.Thread(target=do_stuff,args=(q,Files,))
worker.setDaemon(True)
worker.start()
print worker.is_alive()
print threading.active_count()
print threading.enumerate()
I got False for the is_alive() function and there's only one thread (the main thread) in the active thread list.
What am I doing wrong here?
Thanks a lot!