[New-bugs-announce] [issue34634] New asyncio streams API

Andrew Svetlov report at bugs.python.org
Tue Sep 11 17:18:02 EDT 2018


New submission from Andrew Svetlov <andrew.svetlov at gmail.com>:

Currently, we have separate classes: reader and writer.

It is very inconvenient: these classes are tightly coupled internally, there is no sense to have two objects to the single logical entity.

The second problem is `writer.write()` synchronous API. To support flow control user should call `await writer.drain()` after every `writer.write()` call. But he/she can forget about drain() easy.

`writer.write()` should be softly deprecated in favor of `await writer.send()`. `writer.writelines()` is not very useful, better to merge all buffers before `await stream.send(data)` call. `writelines` should be softly deprecated as well without async replacement.

The last issue is `writer.close()` which should always be used in conjunction with `await writer.wait_closed()`. Let's return a future from `writer.close()`. The encouraged usage becomes `await writer.close()`. 
To immediate closing let's add `writer.abort()` sync function which cleans up resources without waiting for actual closing.

----------
messages: 325064
nosy: asvetlov
priority: normal
severity: normal
status: open
title: New asyncio streams API

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


More information about the New-bugs-announce mailing list