Stop Windows test runs from running out of loopback ports (#1839)
Some checks are pending
CI / Perform Lint Checks (3.15) (push) Waiting to run
CI / Python 3.11 on macos-latest (push) Blocked by required conditions
CI / Python 3.12 on macos-latest (push) Blocked by required conditions
CI / Python 3.13 on macos-latest (push) Blocked by required conditions
CI / Python 3.14 on macos-latest (push) Blocked by required conditions
CI / Python 3.15 on macos-latest (push) Blocked by required conditions
CI / Python 3.11 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.12 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.13 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.14 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.15 on ubuntu-latest (push) Blocked by required conditions
CI / Python 3.11 on windows-latest (push) Blocked by required conditions
CI / Python 3.12 on windows-latest (push) Blocked by required conditions
CI / Python 3.13 on windows-latest (push) Blocked by required conditions
CI / Python 3.14 on windows-latest (push) Blocked by required conditions
CI / Python 3.15 on windows-latest (push) Blocked by required conditions
CodeQL Checks / Analyze (python) (push) Waiting to run

Windows has no native socketpair, so the self-pipe of every asyncio event
loop is a loopback TCP connection, and closing it leaves a port in
TIME_WAIT for two minutes. With a new event loop for each test, a run
that gets through about 16,000 tests within two minutes uses up the
dynamic port range, and the Windows test jobs hang until the 6-hour job
limit.

This PR runs the tests on one event loop per session, so a full run
opens about 100 socket pairs instead of about 26,000, and runs the
Windows jobs with xdist again.

In details:
- `asyncio_default_fixture_loop_scope` and
  `asyncio_default_test_loop_scope` are `session`.
- CI: Windows runs `pytest -n auto` like the other OSes, and the test
  jobs get a 30-minute limit.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ZeliardM
2026-11-06 18:50:15 -05:00
committed by GitHub
parent 0f5faab560
commit a679bc516f
2 changed files with 6 additions and 6 deletions

View File

@@ -54,6 +54,7 @@ jobs:
name: Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }}
needs: lint
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
python-version: [3.11, 3.12, 3.13, 3.14, 3.15]
@@ -80,11 +81,7 @@ jobs:
id: run-pytests-with-code-coverage
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
uv run pytest -n0 --cov kasa --cov-report xml
else
uv run pytest -n auto --cov kasa --cov-report xml
fi
uv run pytest -n auto --cov kasa --cov-report xml
- name: Upload Code Coverage to Codecov
id: upload-code-coverage-to-codecov