-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Raise cancelled on closed #2640
Raise cancelled on closed #2640
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2640 +/- ##
==========================================
+ Coverage 97.92% 97.92% +<.01%
==========================================
Files 38 38
Lines 7265 7268 +3
Branches 1261 1262 +1
==========================================
+ Hits 7114 7117 +3
Misses 47 47
Partials 104 104
Continue to review full report at Codecov.
|
LGTM changes approved, thanks! |
but please first I would ask you to synchronize your branch with the master one. |
@pfreixes Done! (i guess merge is enough for further rebase&squash? ) |
thanks! |
Hold on! |
@asvetlov |
Taking into account that write_eof calls the drain and it can have as a side effect a cancellation error if the client disconnects, don't we have to try to handle both cases in such a way that the developer can catch easily them using just one exception? |
Yeps forgot my last comments, drain as other waiters are wake up with the proper exception once the connection gets closed. Should we use a [1] https://docs.python.org/3/library/exceptions.html#ConnectionError |
asyncio's FlowControlMixin uses ConnectionResetError, so we could use it too, but I have a concern whether transport could be closed only on the other than aiohttp side (otherwise usual ConnectionError looks as a better match to me). |
How do you distinguish between a local task cancel and a remote socket disconnect? I have an app which needs to make that distinction. |
No way right now. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
What do these changes do?
Add raising of asyncio.CancelledError to PayloadWriter write() method to avoid writing to closing transport.
Are there changes in behavior for the user?
According to #2499 (comment) is was possible to catch this situation earlier by manually checking transport status of request. Thus, change should not broke any previously written code.
Related issue number
Resolves #2499
Checklist
CHANGES
folder