Recently, a queue design has been introduced regarding the ability to defer processing, as well as implement FIFO, etc.
I looked through the documentation, trying to get an approximate queue in order to understand how to implement it in my own project / program. But I have problems running this code:
import queue def worker(): while True: item = q.get() do_work(item) q.task_done() def main(): q = queue.Queue(maxsize=0) for i in range(num_worker_threads): t = Thread(target=worker) t.daemon = True t.start() for item in source(): q.put(item) q.join()
Question: I would like someone to explain what the for loops do, I get an error when I run the code, so I need to miss something.
Problem: NameError: global name 'num_worker_threads' not defined
Thank you from the newbie - Python -
Bain Jan 29 '13 at 14:47 2013-01-29 14:47
source share