extmod/uasyncio: Add StreamReader/StreamWriter as aliases of Stream cls.

To be compatible with CPython.  Fixes issue #5847.
This commit is contained in:
Damien George 2020-04-02 00:51:00 +11:00
parent aca19c25d2
commit f97b5395ed
3 changed files with 9 additions and 1 deletions

View File

@ -177,7 +177,8 @@ TCP stream connections
.. class:: Stream() .. class:: Stream()
This represents a TCP stream connection. To minimise code this class implements This represents a TCP stream connection. To minimise code this class implements
both a reader and a writer. both a reader and a writer, and both ``StreamReader`` and ``StreamWriter`` alias to
this class.
.. method:: Stream.get_extra_info(v) .. method:: Stream.get_extra_info(v)

View File

@ -12,6 +12,8 @@ _attrs = {
"Lock": "lock", "Lock": "lock",
"open_connection": "stream", "open_connection": "stream",
"start_server": "stream", "start_server": "stream",
"StreamReader": "stream",
"StreamWriter": "stream",
} }
# Lazy loader, effectively does: # Lazy loader, effectively does:

View File

@ -53,6 +53,11 @@ class Stream:
self.out_buf = b"" self.out_buf = b""
# Stream can be used for both reading and writing to save code size
StreamReader = Stream
StreamWriter = Stream
# Create a TCP stream connection to a remote host # Create a TCP stream connection to a remote host
async def open_connection(host, port): async def open_connection(host, port):
from uerrno import EINPROGRESS from uerrno import EINPROGRESS