Skip to content

gh-159123: fix ResourceWarning flake in asyncio SSL handshake failure tests - #160209

Merged
kumaraditya303 merged 1 commit into
python:mainfrom
kumaraditya303:gh-159123-ssl-handshake-server-close
Oct 22, 2026
Merged

kumaraditya303 merged 1 commit into
python:mainfrom
kumaraditya303:gh-159123-ssl-handshake-server-close

Conversation

@kumaraditya303

@kumaraditya303 kumaraditya303 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Run the loop until Server.wait_closed() completes so the server-side transport of the failed handshake is closed before the loop.

…ailure tests

test_create_server_ssl_verify_failed, test_create_unix_server_ssl_verify_failed
and test_create_server_ssl_match_failed stopped the loop as soon as the client
handshake failed and then only called Server.close(), which closes the
listening sockets but not the accepted server-side transport. If the TLS
alert/EOF from the client reached the server socket in the last loop
iteration, the transport's _call_connection_lost callback stayed queued when
the loop was closed, leaving the socket open and emitting
"unclosed transport <_SelectorSocketTransport closing fd=N>".

Run the loop until Server.wait_closed() completes so the server-side
transport of the failed handshake is closed before the loop is.
@kumaraditya303

Copy link
Copy Markdown
Contributor Author

!buildbot FreeBSD

@bedevere-bot

Copy link
Copy Markdown

🤖 New build scheduled with the buildbot fleet by @kumaraditya303 for commit f14237c 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F160209%2Fmerge

The command will test the builders whose names match following regular expression: FreeBSD

The builders matched are:

  • AMD64 FreeBSD16 Non-Debug PR
  • AMD64 FreeBSD15 PR
  • AMD64 FreeBSD16 PR
  • AMD64 FreeBSD15 NoGIL PR
  • AMD64 FreeBSD Refleaks PR
  • AMD64 FreeBSD14 PR

@kumaraditya303
kumaraditya303 merged commit 5d88764 into python:main Oct 22, 2026
70 of 71 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @kumaraditya303 for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14, 3.15.
🐍🍒⛏🤖

@kumaraditya303
kumaraditya303 deleted the gh-159123-ssl-handshake-server-close branch October 22, 2026 08:46
@bedevere-app

bedevere-app Bot commented Oct 22, 2026

Copy link
Copy Markdown

GH-160225 is a backport of this pull request to the 3.15 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.15 bugs and security fixes label Oct 22, 2026
@bedevere-app

bedevere-app Bot commented Oct 22, 2026

Copy link
Copy Markdown

GH-160226 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Oct 22, 2026
@vstinner

Copy link
Copy Markdown
Member

Oh I forgot that server close is asynchronous and should be awaited.

@vstinner

Copy link
Copy Markdown
Member

Thanks for the fix!

kumaraditya303 added a commit that referenced this pull request Oct 22, 2026
…failure tests (GH-160209) (#160226)

gh-159123: fix ResourceWarning flake in asyncio SSL handshake failure tests (GH-160209)
(cherry picked from commit 5d88764)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
kumaraditya303 added a commit that referenced this pull request Oct 22, 2026
…failure tests (GH-160209) (#160225)

gh-159123: fix ResourceWarning flake in asyncio SSL handshake failure tests (GH-160209)
(cherry picked from commit 5d88764)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants