Skip to content

gh-155934: Fix socket leak and silent error for asyncio accepted connections - #155936

Open
danielKim614 wants to merge 1 commit into
python:mainfrom
danielKim614:gh-155934-accept-error
Open

gh-155934: Fix socket leak and silent error for asyncio accepted connections#155936
danielKim614 wants to merge 1 commit into
python:mainfrom
danielKim614:gh-155934-accept-error

Conversation

@danielKim614

Copy link
Copy Markdown
Contributor

When protocol_factory() or transport creation raises for an accepted connection in BaseSelectorEventLoop._accept_connection2(), close the accepted socket (it would otherwise leak until garbage collection) and report the error via the loop exception handler even when debug mode is disabled.

Reporting stays debug-only once the transport exists, so await waiter failures such as SSL handshake errors from port scanners are not reported unconditionally.

This is the server-side counterpart of gh-153134 (gh-153133).

The new tests fail without the fix and pass with it. The full test_asyncio suite passes, including -R 3:3 refleak runs on test_selector_events.

@danielKim614

danielKim614 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

I already mentioned you in the issue, but just in case you missed it @hugovk @corona10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants