Skip to content

Commit

Permalink
[3.5] Fix stream .read() / .readany() / .iter_any() (#3525) (#3527) (#…
Browse files Browse the repository at this point in the history
…3528)

(cherry picked from commit 5c4cb82)

Co-authored-by: Коренберг Марк <[email protected]>
  • Loading branch information
asvetlov and socketpair authored Jan 12, 2019
1 parent 99335f4 commit 8504117
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 8504117

Please sign in to comment.