title: Signal the end of jobs on the Queue?
body: <p>Here's an example code of from Python documentation:</p>
  
  <pre><code>def worker():
      while True:
          item = q.get()
          do_work(item)
          q.task_done()
  
  q = Queue()
  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
  </code></pre>
  
  <p>I modified it to fit my use case like this:</p>
  
  <pre><code>import threading
  from Queue import Queue
  
  max_threads = 10
  
  q = Queue(maxsize=max_threads + 2)
  
  def worker():
    while True:
      task = q.get(1)
      # do something with the task
      q.task_done()
  
  for i in range(max_threads):
    t = threading.Thread(target=worker)
    t.start()
  
  for task in ['a', 'b', 'c']:
    q.put(task)
  
  q.join()
  </code></pre>
  
  <p>When I execute it, debugger says that all the jobs were executed, but q.join() seems to wait forever. How can I send a signal to the worker threads that I already sent all the tasks?</p>