Ignore protocol exceptions after it is closed#6321
Conversation
155744c to
b046b2c
Compare
Codecov Report
@@ Coverage Diff @@
## master #6321 +/- ##
=======================================
Coverage 93.31% 93.32%
=======================================
Files 103 103
Lines 30369 30374 +5
Branches 2731 2730 -1
=======================================
+ Hits 28340 28347 +7
+ Misses 1852 1850 -2
Partials 177 177
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Dreamsorcerer
left a comment
There was a problem hiding this comment.
Confirmed that this fixes #4526
Co-authored-by: Sam Bull <[email protected]>
Backport to 3.8: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 58da337 on top of patchback/backports/3.8/58da3373a21211bbde21f1393475e73f53a5671d/pr-6321 Backporting merged PR #6321 into master
🤖 @patchback |
Backport to 3.9: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 58da337 on top of patchback/backports/3.9/58da3373a21211bbde21f1393475e73f53a5671d/pr-6321 Backporting merged PR #6321 into master
🤖 @patchback |
|
Backporting doesn't make sense, |
Issue
I've recently started to experience strange ssl exceptions with
aiohttp 4+(master branch) with the following message:Reproducer
Code to reproduce the error.
Description
After some digging I found out a related issue in python bug tracker:
https://bugs.python.org/issue39951
It describes possible scenario for this type of SSL exception to happen:
close notify.close notify.In
aiohttpthis exception happens whenBaseConnector._releaseis called withshould_close=Trueaiohttp/aiohttp/connector.py
Lines 628 to 633 in d149eff
After execution of this branch
protocolis on its way to be removed by GC. But if theprotocol.connection_lostis called with exception before the removal (which is exactly what is happening) theprotocol.closedfuture will store this exception.aiohttp/aiohttp/client_proto.py
Lines 73 to 79 in d149eff
During the removal of the
protocolobject, the following exception will be produced:Future exception was never retrieved.Solution
I solved it by setting the result of
self.closedtoNoneexplicitly during the_releasecall withshould_close=True.Related issue number
Fixes #4526
Checklist
CONTRIBUTORS.txtCHANGESfolder<issue_id>.<type>for example (588.bugfix)issue_idchange it to the pr id after creating the pr.feature: Signifying a new feature..bugfix: Signifying a bug fix..doc: Signifying a documentation improvement..removal: Signifying a deprecation or removal of public API..misc: A ticket has been closed, but it is not of interest to users.