mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-11-08 12:57:20 +00:00
Stop Windows test runs from running out of loopback ports (#1839)
Some checks failed
CI / Perform Lint Checks (3.15) (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.15 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.15 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
CI / Python 3.15 on windows-latest (push) Has been cancelled
Some checks failed
CI / Perform Lint Checks (3.15) (push) Has been cancelled
CodeQL Checks / Analyze (python) (push) Has been cancelled
CI / Python 3.11 on macos-latest (push) Has been cancelled
CI / Python 3.12 on macos-latest (push) Has been cancelled
CI / Python 3.13 on macos-latest (push) Has been cancelled
CI / Python 3.14 on macos-latest (push) Has been cancelled
CI / Python 3.15 on macos-latest (push) Has been cancelled
CI / Python 3.11 on ubuntu-latest (push) Has been cancelled
CI / Python 3.12 on ubuntu-latest (push) Has been cancelled
CI / Python 3.13 on ubuntu-latest (push) Has been cancelled
CI / Python 3.14 on ubuntu-latest (push) Has been cancelled
CI / Python 3.15 on ubuntu-latest (push) Has been cancelled
CI / Python 3.11 on windows-latest (push) Has been cancelled
CI / Python 3.12 on windows-latest (push) Has been cancelled
CI / Python 3.13 on windows-latest (push) Has been cancelled
CI / Python 3.14 on windows-latest (push) Has been cancelled
CI / Python 3.15 on windows-latest (push) Has been cancelled
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:
7
.github/workflows/ci.yml
vendored
7
.github/workflows/ci.yml
vendored
@@ -54,6 +54,7 @@ jobs:
|
|||||||
name: Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }}
|
name: Python ${{ matrix.python-version}} on ${{ matrix.os }}${{ fromJSON('[" (extras)", ""]')[matrix.extras == ''] }}
|
||||||
needs: lint
|
needs: lint
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
|
timeout-minutes: 30
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
python-version: [3.11, 3.12, 3.13, 3.14, 3.15]
|
python-version: [3.11, 3.12, 3.13, 3.14, 3.15]
|
||||||
@@ -80,11 +81,7 @@ jobs:
|
|||||||
id: run-pytests-with-code-coverage
|
id: run-pytests-with-code-coverage
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ runner.os }}" == "Windows" ]]; then
|
uv run pytest -n auto --cov kasa --cov-report xml
|
||||||
uv run pytest -n0 --cov kasa --cov-report xml
|
|
||||||
else
|
|
||||||
uv run pytest -n auto --cov kasa --cov-report xml
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Upload Code Coverage to Codecov
|
- name: Upload Code Coverage to Codecov
|
||||||
id: upload-code-coverage-to-codecov
|
id: upload-code-coverage-to-codecov
|
||||||
|
|||||||
@@ -114,7 +114,10 @@ markers = [
|
|||||||
"requires_dummy: test requires dummy data to pass, skipped on real devices",
|
"requires_dummy: test requires dummy data to pass, skipped on real devices",
|
||||||
]
|
]
|
||||||
asyncio_mode = "auto"
|
asyncio_mode = "auto"
|
||||||
asyncio_default_fixture_loop_scope = "function"
|
# One event loop for the run, not one per test: on Windows each loop opens a
|
||||||
|
# loopback TCP connection, and thousands of them use up the dynamic ports.
|
||||||
|
asyncio_default_fixture_loop_scope = "session"
|
||||||
|
asyncio_default_test_loop_scope = "session"
|
||||||
#timeout = 10
|
#timeout = 10
|
||||||
# dist=loadgroup enables grouping of tests into single worker.
|
# dist=loadgroup enables grouping of tests into single worker.
|
||||||
# required as caplog doesn't play nicely with multiple workers.
|
# required as caplog doesn't play nicely with multiple workers.
|
||||||
|
|||||||
Reference in New Issue
Block a user