title: Learning about Queue module in python (how to run it)
body: <p>Was recently introduced to the queue design in regards to ability to defer processing as well as implementing a "FIFO" etc. </p>
  
  <p>Looked through the documentation in attempt to get a sample queue going to understand how to implement it in my own design / program. But I'm having issues with just running this code: </p>
  
  <pre><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()       # block until all tasks are done
  
  main()
  </code></pre>
  
  <p>Question: Would like someone to explain what the for loops are doing, I get an error just running the code so I have to be missing something. </p>
  
  <p>Problem Error that occurs: 
  <strong>NameError: global name 'num_worker_threads' is not defined</strong></p>
  
  <p>Thank you from a -Python Novice-</p>