Title: may lead to a blocking behavior
Type: Stage:
Components: asyncio Versions: Python 3.7, Python 3.6, Python 3.5
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: malinoff, wumpus, yselivanov
Priority: normal Keywords:

Created on 2017-08-01 07:41 by malinoff, last changed 2018-01-11 18:43 by wumpus.

Messages (1)
msg299610 - (view) Author: Dmitry Malinovsky (malinoff) Date: 2017-08-01 07:41
When there is a huge amount of `writer.write` calls followed by `await writer.drain()` on a non-paused channel, and there are no other coroutine switches, `await writer.drain()` immediately returns without a switch. This is because `` do not `yield` or `yield from` on a non-paused stream.

Use-case: AMQP basic.publish method, for which the broker (rabbitmq) do not send any replies back. Trying to publish 4k messages results in the following warnings (PYTHONASYNCIODEBUG env variable is set):
`Executing <Handle <TaskWakeupMethWrapper object at 0x1106fde28>(<Future>) created at /Users/malinoff/Projects/ideas/amqproto/amqproto/> took 2.371 seconds`
2.371 seconds is the time spent on 4k `basic_publish` calls.

You can find the test itself on github:

An easy fix would be to replace return ( with yield (and but the code below under the else clause; I'm willing to prepare a pull request), but maybe I'm missing something and such behavior is intentional?
Date User Action Args
2018-01-11 18:43:33wumpussetnosy: + wumpus
2017-08-01 07:41:06malinoffcreate