Skip to content

Commit

Permalink
Fix stream .read() / .readany() / .iter_any() (#3525) (#3527)
Browse files Browse the repository at this point in the history
  • Loading branch information
socketpair authored and asvetlov committed Jan 11, 2019
1 parent a86af67 commit 5c4cb82
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 5c4cb82

Please sign in to comment.