From 85041179340c54da1d74f2972de7a9da5dae82d7 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Sat, 12 Jan 2019 11:17:37 +0200 Subject: [PATCH] [3.5] Fix stream .read() / .readany() / .iter_any() (#3525) (#3527) (#3528) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit 5c4cb823) Co-authored-by: Коренберг Марк --- 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)