From aaa518f588a44d5a99f851ecf7e74998926508ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=BE=D1=80=D0=B5=D0=BD=D0=B1=D0=B5=D1=80=D0=B3=20?= =?UTF-8?q?=D0=9C=D0=B0=D1=80=D0=BA=20=28=D0=9D=D0=BE=D1=83=D1=82=D0=B1?= =?UTF-8?q?=D1=83=D0=BA=20HP=29?= Date: Sat, 12 Jan 2019 03:02:08 +0500 Subject: [PATCH] Fix stream .read() / .readany() / .iter_any() (#3525) --- aiohttp/streams.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/aiohttp/streams.py b/aiohttp/streams.py index 4bb96ab6e82..412e2002f30 100644 --- a/aiohttp/streams.py +++ b/aiohttp/streams.py @@ -362,7 +362,10 @@ async def read(self, n: int=-1) -> bytes: blocks.append(block) return b''.join(blocks) - if not self._buffer and not self._eof: + # TODO: should be `if` instead of `while` + # because waiter maybe triggered on chunk end, + # without feeding any data + while not self._buffer and not self._eof: await self._wait('read') return self._read_nowait(n) @@ -371,7 +374,10 @@ async def readany(self) -> bytes: if self._exception is not None: raise self._exception - if not self._buffer and not self._eof: + # TODO: should be `if` instead of `while` + # because waiter maybe triggered on chunk end, + # without feeding any data + while not self._buffer and not self._eof: await self._wait('readany') return self._read_nowait(-1)