[issue18277] Queue is empty right after put from the same process/thread

shwouchk report at bugs.python.org
Sat Jun 22 00:12:42 CEST 2013


shwouchk added the comment:

The major difference with the issue you referenced is that the behavior in #17985 is clearly stated and warned against in the docs (Queue.Empty being inconsistent with Queue.size), whereas this is not.

As for the actual behavior problem: Imagine you build an abstraction atop Queue (For example and specifically, a queue iterator). This iterator might return None or a similar sentinel if there is nothing on the queue.

Since you find the construct useful and would like to keep uniformity in the program, there is a place you use this abstraction in a fairly tight loop to pass messages from one part of the program to another part, in the same process and thread. Now the logic of the program does not work correctly as it was based on the assumption that in a single process Queue would work "as expected".

The problem is not the exception but with having an abstraction built atop Queue that works right with respect to program logic both when you use it in one thread and in multiple ones.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18277>
_______________________________________


More information about the Python-bugs-list mailing list