← 输入框|bugs.python.org|刷新

➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

作者 esrse
收信人 asvetlov, esrse, yselivanov
日期 2019-11-21.03:25:54
SpamBayes Score -1.0
Marked as misclassified 是
Message-id <1574306754.82.0.07273997342.issue38874@roundup.psfhosted.org>
In-reply-to
内容
Hi

The python document says that asyncio.Queue is FIFO queue. But it is not true
when the queue is full and multi tasks are putting items into it
simultaneously. I know the document does not explicitly mention that
asyncio.Queue is multi producer queue, but also there does not exist any note
that it may be corrupt if used by multi producers.

I found the below scenario happens when the asyncio.Queue is full and multi
tasks are putting into it simultaneously. Let me explain this.

When a queue is full, putters are awaiting here: https://github.com/python/cpython/blob/d67279147ace3b63187e5d75a15c345264f39e85/Lib/asyncio/queues.py#L125

And the first of them is waken up here: https://github.com/python/cpython/blob/d67279147ace3b63187e5d75a15c345264f39e85/Lib/asyncio/queues.py#L188

Before the first putter hands over the control of execution, new putter
calls the .put() method so the queue is not full at this point that it calls
.put_nowait() immediately here: https://github.com/python/cpython/blob/d67279147ace3b63187e5d75a15c345264f39e85/Lib/asyncio/queues.py#L140

If this happens the new putter puts earlier than other awaiting putters.

I hope the queue gets fixed to work correctly in this case.

Thanks,

  Junyeong
历史
日期 用户 动作 参数
2019-11-21 03:25:54esrse修改recipients: + esrse, asvetlov, yselivanov
2019-11-21 03:25:54esrse修改messageid: <1574306754.82.0.07273997342.issue38874@roundup.psfhosted.org>
2019-11-21 03:25:54esrse链接issue38874 messages
2019-11-21 03:25:54esrse创建