[New-bugs-announce] [issue11987] queue.Queue.put should acquire mutex for unfinished_tasks

patrick vrijlandt report at bugs.python.org
Tue May 3 21:30:08 CEST 2011

New submission from patrick vrijlandt <patrick.vrijlandt at gmail.com>:

Line 154 in standard library's queue.py, in the definition of Queue.put() is: 
self.unfinished_tasks += 1

This line should be protected by acquiring the all_tasks_done lock.
Theoretically, the increment could occur somewhere during task_done()!

Additional note:
Personally, I would like the increment to occur *before* instead of *after* _put(). This is because I would like to be able to implement a _put() that does not put everything. This put should be able to undo the increment. As it is, calling task_done() from put might decrease the counter to zero inadvertently.

components: Library (Lib)
messages: 135063
nosy: patrick.vrijlandt
priority: normal
severity: normal
status: open
title: queue.Queue.put should acquire mutex for unfinished_tasks
type: behavior
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list