[issue24449] Please add async write method to asyncio.StreamWriter

Guido van Rossum report at bugs.python.org
Sun Jun 14 20:47:42 CEST 2015


Guido van Rossum added the comment:

Most people actually are better off with just write(), and an API with more choices is not necessarily better. I'm sure this has come up before, I could've sworn it was you, sorry if it wasn't.

Here's one reason why I don't like your proposed API. The read() and write() calls *aren't* symmetric: When you call read(), you are interested in the return value. If you forget the "yield from" (or 'async') your use of the return value will most likely raise an exception immediately, so you will notice (and pinpoint) the bug in your code instantly. But with write() there is no natural return value, so if write() was a coroutine, the common mistake (amongst beginners) of forgetting the "yield from" or 'async' would be much harder to debug -- your program happily proceeds, but now it's likely hung, waiting for a response that it won't get (because the other side didn't get what you meant to write) or perhaps you get a cryptic error (because the other side saw the thing you wrote next).

----------

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


More information about the Python-bugs-list mailing list