Skip to content

Avoid Python test server port-allocation races#3667

Open
kpumuk wants to merge 1 commit into
apache:masterfrom
kpumuk:py-ephemeral-test-ports
Open

Avoid Python test server port-allocation races#3667
kpumuk wants to merge 1 commit into
apache:masterfrom
kpumuk:py-ephemeral-test-ports

Conversation

@kpumuk

@kpumuk kpumuk commented Jul 23, 2026

Copy link
Copy Markdown
Member

RunClientServer.py selected an unused port by binding a temporary socket, closing it, and then launching TestServer.py on the same port. Another process could claim the port during that gap, causing intermittent macOS failures with OSError: [Errno 48] Address already in use.

Let each test server bind port 0 so the kernel allocates and owns the port, then report the bound port to the parent before the client starts. The same reporting path covers regular, SSL, and HTTP test servers; ephemeral HTTP tests bind to loopback and avoid hostname lookup during startup.

Representative failures include macOS 26 with Python 3.11, macOS 14 with Python 3.13, Intel macOS 15 with Python 3.10, macOS 26 with Python 3.10, and macOS 15 with Python 3.13. Each failed in the Python check while binding a test-server socket with OSError: [Errno 48] Address already in use.

  • Did you create an Apache Jira ticket? (Request account here, not required for trivial changes) — Skipped at maintainer request for this focused test-harness fix.
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"? — No ticket exists.
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources. — Not applicable; this changes Python test-harness code.

Client: py

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
@kpumuk
kpumuk requested a review from mhlakhani as a code owner July 23, 2026 19:07
Copilot AI review requested due to automatic review settings July 23, 2026 19:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@mergeable mergeable Bot added the python label Jul 23, 2026
@kpumuk
kpumuk requested a review from Jens-G July 23, 2026 20:41
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