summaryrefslogtreecommitdiff
path: root/extmod/uasyncio/stream.py
diff options
context:
space:
mode:
authorMike Teachman <mike.teachman@gmail.com>2021-06-03 09:43:56 -0700
committerDamien George <damien@micropython.org>2021-06-15 13:13:35 +1000
commitb0b8ebc4f6e337e18c79367ccc5f379dfa8681d9 (patch)
treea38455b2c272cad252490335e2151081eea9878f /extmod/uasyncio/stream.py
parent95048129b1d93854c25f501c02801929aeeb23f0 (diff)
extmod/uasyncio: Add readinto() method to Stream class.
With docs and a multi-test using TCP server/client. This method is a MicroPython extension, although there is discussion of adding it to CPython: https://bugs.python.org/issue41305 Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
Diffstat (limited to 'extmod/uasyncio/stream.py')
-rw-r--r--extmod/uasyncio/stream.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/extmod/uasyncio/stream.py b/extmod/uasyncio/stream.py
index 2a259e618..3a68881da 100644
--- a/extmod/uasyncio/stream.py
+++ b/extmod/uasyncio/stream.py
@@ -30,6 +30,10 @@ class Stream:
yield core._io_queue.queue_read(self.s)
return self.s.read(n)
+ async def readinto(self, buf):
+ yield core._io_queue.queue_read(self.s)
+ return self.s.readinto(buf)
+
async def readexactly(self, n):
r = b""
while n: