I am trying to write a program that creates new threads in a loop and does not wait for them to complete. Since I understand this, if I use .start () in a thread, my main loop should just continue and the other thread will shut down and do its work at the same time
However, as soon as my new thread starts, the loop blocks until the thread terminates. I misunderstood how threads work in python, or is there something stupid that I am doing.
here is my code for creating new threads.
def MainLoop():
print 'started'
while 1:
if not workQ.empty():
newThread = threading.Thread(target=DoWorkItem(), args=())
newThread.daemon = True
newThread.start()
else:
print 'queue empty'
thanks everyone
B_o_b source
share