-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Treat asyncio resume_reading
error as a closed connection
#201
Treat asyncio resume_reading
error as a closed connection
#201
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, okay, sounds like a sensible ugly fix to an asyncio weakness.
Note: have we tried to see if this reproduces on anyio (rubbing in asyncio)?
@florimondmanca PS |
e23e01d
to
513b4b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello! I've got some nitpicks on the code comment… Other than that, I'm not sure how confident we are merging this change? Can you point here to a comment with a test setup that allows reproducing this 100% of the time, to verify this is fixed with this PR?
httpcore/_backends/asyncio.py
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Nit) Tweaking the leading spaces here…
# 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 | |
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
I created a gist with the test file https://gist.github.com/cdeler/86d99a42c5bfb522bc15cac8d27824aa Just run the script using python3, also you can check that the bug is not reproducible under other backends (just run |
Co-authored-by: Florimond Manca <florimond.manca@gmail.com> Co-authored-by: florimondmanca <florimond.manca@gmail.com>
Co-authored-by: Florimond Manca <florimond.manca@gmail.com>
7c84da4
to
bdd8570
Compare
Probably I can add the test from the gist to our CI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely, thanks!
Closes encode/httpx#1213
There is a gist in the issue, which can help you reproduce the error: link . You can also switch the async backend and check, that the error appears only when we
asyncio
backend.The introduced fix mends the error, so that the error message caused by the exception looks like:
instead of the original stacktrace from the issue
There is a problem:
I cannot figure out how to make a unit test for this error