kopia lustrzana https://github.com/micropython/micropython-lib
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.pull/149/head
rodzic
f5fdebed34
commit
a8d85e28d0
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue