bpo-36889: Merge asyncio streams by asvetlov · Pull Request #13251 · python/cpython (original) (raw)

The main part is basically done. The functionality is test covered for all significant code paths because the PR doesn't change too much but "just" merges StreamReader and StreamWriter.

There are two options for future steps:

  1. Add several tests for StreamMode related API, write NEWS, merge and make other improvements in following pull requests. I prefer this way for the sake of simplifying the review process. I have a strong feeling that the proposed change is viable. We did miss it starting from Python 3.5.
  2. Another approach is to keep working on this branch to collect all wish changes at once. The review becomes complicated though.

The wish list is:

  1. Add asyncio.connect() and asyncio.StreamServer() to avoid working with stream, stream where was reader, writer. The same for UNIX sockets.
    StreamServer should be mimic to asyncio.AbstractServer but without boilerplate. The usage is:
async with StreamServer(host, port) as server:
   await server.serve_forever()

StreamServer should create low-level asyncio server (loop.create_server()) with start_serving=False. We discussed the server design with @1st1 offline already.

  1. Support both Windows and UNIX pipes (a new API whose implementation is really trivial with unified streams). See loop.connect_read_pipe and loop.connect_write_pipe for the context.
  2. Rewrite SubprocessStreamProtocol to add subprotocols from stdin, stdout, and stderr. It can simplify things a lot.