[issue38874] asyncio.Queue: putting items out of order when it is full

Junyeong Jeong report at bugs.python.org
Thu Nov 21 00:59:06 EST 2019


Junyeong Jeong <rhdxmr at gmail.com> added the comment:

> The items that haven't finished the put aren't actually "in" the queue yet, so I don't see how non-FIFO order of insertion violates any FIFO guarantees for the contents of the queue; until the items are actually "in", they're not sequenced for the purposes of when they come "out". Mandating such a guarantee effectively means orchestrating a queue with a real maxsize equal to the configured maxsize plus the total number of coroutines competing to put items into it.

Your explanation is correct technically. But without enough explanation, this
behavior can confuse many users.

For instance it happens to put data into asyncio.Queue at asyncio protocol
callbacks by creating new task. This logic will work nicely for a long time but
in the corner case the queue gets full and at the point of view of a consumer
the data come out from the queue are out of order.

IMHO, it would be better to add some note into the document, describing what
FIFO means in regard to asyncio.Queue.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38874>
_______________________________________


More information about the Python-bugs-list mailing list