Repository navigation
[3.14] gh-162606: Avoid find_unused_port() races in asyncio tests (GH-162607) - #162620
Merged
Merged
Conversation
…honGH-162607) * pythongh-162606: Fix port races in asyncio connection-refused tests test_create_connection_local_addr_skip_different_family and test_sock_client_fail expected a connect to an "unused" port to be refused, but the port was not reserved, so a parallel test could start listening on it and the connect would succeed. Keep a bound, non-listening socket open for the duration of each test instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pythongh-162606: Avoid find_unused_port() races in more asyncio tests Bind servers to port 0 instead of picking a port first and binding it later, retry test_create_connection_local_addr on EADDRINUSE, and keep the port of test_open_connection_happy_eyeball_refcycles reserved on both loopback addresses so the connection is reliably refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pythongh-162606: Remove unused import in test_proactor_events Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * pythongh-162606: Accept TimeoutError for non-listening ports on macOS macOS and iOS fail a connect to a bound but non-listening port with ETIMEDOUT immediately instead of ECONNREFUSED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- (cherry picked from commit 4b66b873d07f69f90d93c74675d6989bd540512d) Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
miss-islington
requested review from
1st1,
asvetlov,
kumaraditya303 and
willingc
as code owners
November 25, 2026 14:38
asvetlov
enabled auto-merge (squash)
November 25, 2026 14:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
test_create_connection_local_addr_skip_different_family and
test_sock_client_fail expected a connect to an "unused" port to be
refused, but the port was not reserved, so a parallel test could start
listening on it and the connect would succeed. Keep a bound,
non-listening socket open for the duration of each test instead.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Bind servers to port 0 instead of picking a port first and binding it
later, retry test_create_connection_local_addr on EADDRINUSE, and keep
the port of test_open_connection_happy_eyeball_refcycles reserved on
both loopback addresses so the connection is reliably refused.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
macOS and iOS fail a connect to a bound but non-listening port with
ETIMEDOUT immediately instead of ECONNREFUSED.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com
(cherry picked from commit 4b66b87)
Co-authored-by: Andrew Svetlov andrew.svetlov@gmail.com
Co-authored-by: Claude Opus 5.5 noreply@anthropic.com