The asyncio API could be improved by doing the following:
Combining StreamReader and StreamWriter to a single Stream classThis is useful because currently the user needs to know that he needs to close the writer and not the reader which is confusing.
I think that the cleanest way to make this work is that the class Stream will hold a reader and a writer and then it will handle the api calls by calling the corresponding reader / writer member functions.
Make the StreamWriter.write a coroutine and make it call drainCurrently the intended use to drain is as follows:
Why should there be 2 api functions when write could do all this in a single function call.
Adding an aclose coroutine to shutdown the stream gracefullyCurrently there is only one implementation of close and it's not a coroutine, meaning that the only thing it can do it shutdown the socket forcefully.
This is how Trio does it: https://trio.readthedocs.io/en/stable/reference-io.html#trio.abc.AsyncResource.aclose