From a8d85e28d00fd2973bfe51302d83543aeef9ca86 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 26 Jan 2017 22:20:29 +0300 Subject: [PATCH] uasyncio: Fix partial reads in StreamReader.read/readline() methods. If None (no data, would block) is received, need to wait for more data, not just read it again immediately. --- uasyncio/uasyncio/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/uasyncio/uasyncio/__init__.py b/uasyncio/uasyncio/__init__.py index aa067406..bc6e37b5 100644 --- a/uasyncio/uasyncio/__init__.py +++ b/uasyncio/uasyncio/__init__.py @@ -79,8 +79,8 @@ class StreamReader: self.s = s def read(self, n=-1): - yield IORead(self.s) while True: + yield IORead(self.s) res = self.s.read(n) if res is not None: break @@ -92,10 +92,10 @@ class StreamReader: def readline(self): if __debug__: log.debug("StreamReader.readline()") - yield IORead(self.s) # if DEBUG and __debug__: # log.debug("StreamReader.readline(): after IORead: %s", s) while True: + yield IORead(self.s) res = self.s.readline() if res is not None: break