Skip to content

Commit

Permalink
Added the fix from PR
Browse files Browse the repository at this point in the history
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>

Co-authored-by: florimondmanca <florimond.manca@gmail.com>
  • Loading branch information
cdeler and florimondmanca committed Oct 2, 2020
1 parent 08e8e41 commit e23e01d
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions httpcore/_backends/asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,19 @@ async def read(self, n: int, timeout: TimeoutDict) -> bytes:
return await asyncio.wait_for(
self.stream_reader.read(n), timeout.get("read")
)
except AttributeError: # pragma: nocover
"""
We have to return empty string there due to one ugly bug in asyncio
More information you can find in this issue:
https://github.com/encode/httpx/issues/1213
The empty byte-string returned from there caused
httpcore.RemoteProtocolError at the top level
"""
return b""
except AttributeError as ex: # pragma: nocover
if "resume_reading" in str(ex):
"""
We have to return empty string there,
due to one ugly bug in asyncio
More information you can find in this issue:
https://github.com/encode/httpx/issues/1213
The empty byte-string returned from there caused
httpcore.RemoteProtocolError at the top level
"""
return b""
raise

async def write(self, data: bytes, timeout: TimeoutDict) -> None:
if not data:
Expand Down

0 comments on commit e23e01d

Please sign in to comment.