-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-135836: Fix IndexError in asyncio.create_connection() #135875
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
base: main
Are you sure you want to change the base?
gh-135836: Fix IndexError in asyncio.create_connection() #135875
Conversation
It occurs when non-OSError exception is raised during connection and socket's close() raises OSError.
caa0472
to
2c7545f
Compare
sock.close() | ||
try: | ||
sock.close() | ||
except OSError: |
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.
I am not sure if suppressing this error is correct here.
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.
I think it is okay. It is an error in closing just created connection, it is less interesting than the original non-OSError error.
We do not even know what is this error, because we have no reproducer. ECONNRESET is already ignored in socket.close()
. I suspect that this is similar error (maybe EINTR?) which should always be ignored.
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.
Okay, please add a comment about this with linking to issue as this isn't obvious.
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.
What comment is needed here? Ignoring any OSError is pretty common, and such code usually does not have comment. If there is a comment (e.g. "Ignore broken pipes caused by quitting the pager program."), it specifies the most common cause of error, but in this case we do not know it.
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.
just mention the issue number, no need for elaborate comment
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.
There are two ways to solve this issue:
- add this exception to
my_exceptions
- ignore it.
Otherwise we will get IndexError or, after merging #135845, wrong TimeoutError.
I think that this error is not important.
It occurs when non-OSError exception is raised during connection and socket's close() raises OSError.