Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Jun 24, 2025

It occurs when non-OSError exception is raised during connection and socket's close() raises OSError.

It occurs when non-OSError exception is raised during connection and socket's
close() raises OSError.
@serhiy-storchaka serhiy-storchaka force-pushed the asyncio-create_connection-indexerror branch from caa0472 to 2c7545f Compare June 24, 2025 08:10
sock.close()
try:
sock.close()
except OSError:
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants