Python - What is queue.task_done() used for? : <p>I wrote a script that has multiple threads (created with <code>threading.Thread</code>) fetching URLs from a <code>Queue</code> using <code>queue.get_nowait()</code>, and then processing the HTML. I am new to multi-threaded programming, and am having trouble understanding the purpose of the <code>queue.task_done()</code> function.  </p>

<p>When the <code>Queue</code> is empty, it automatically returns the <code>queue.Empty</code> exception. So I don't understand the need for each thread to call the <code>task_done()</code> function. We know that we're done with the queue when its empty, so why do we need to notify it that the worker threads have finished their work (which has nothing to do with the queue, after they've gotten the URL from it)? </p>

<p>Could someone provide me with a code example (ideally using <code>urllib</code>, file I/O, or something other than fibonacci numbers and printing "Hello") that shows me how this function would be used in practical applications? </p>
