threading/Queue: join() and task_done() not working? (deadlock)
bbxx789_05ss at yahoo.com
Thu Feb 28 12:42:27 CET 2008
On Feb 28, 1:47 am, Gal Aviel <galav... at yahoo.com> wrote:
> 7stud <bbxx789_05ss <at> yahoo.com> writes:
> > What is task_done()? The python docs don't list any such function.
> I'm using Python 2.5 and it's in the docs ...
According to the docs, join() unblocks only after you call task_done()
for every item that was entered into the Queue. However, just because
the Queue size is 1 doesn't mean there aren't other items waiting to
be added to the Queue. With one item in the Queue, presumably the
task-count is 1. But, if you get() an item out of the Queue and
another item is waiting to be added to the Queue, then it seems likely
that the task_count will jump to 2 immediately after calling get().
Thereafter, a call to task_done() will decrement the task_count to 1,
which means join() will continue blocking.
Please recognize that it is very difficult to debug imaginary code.
If you want some help that is more relevant, then post a short example
that demonstrates your problem. Do not post some lengthy program with
cryptic variable names.
More information about the Python-list