Skip to content

Test: one event loop per session instead of the socketpair fixture (do not merge) - #17

Closed
ZeliardM wants to merge 2 commits into
fix/windows-test-hangfrom
probe/session-loop
Closed

ZeliardM wants to merge 2 commits into
fix/windows-test-hangfrom
probe/session-loop

Conversation

@ZeliardM

@ZeliardM ZeliardM commented Nov 6, 2026

Copy link
Copy Markdown
Owner

Test PR on the fork only. Do not merge. It runs the real CI matrix on an alternative to the SO_LINGER fixture in python-kasa#1839.

The diff against fix/windows-test-hang (python-kasa#1839's head, 91d5b93):

  • pyproject.toml: pytest-asyncio's fixture and test loop scopes are session, so the run uses one event loop per worker instead of one per test. Each loop opens a socketpair for its self-pipe; on Windows that is a loopback TCP connection that leaves a port in TIME_WAIT. A full run drops from 26,364 pairs to 102.
  • tests/conftest.py: the Windows-only SO_LINGER fixture is removed (back to master's file).
  • .github/workflows/windows-probe.yml: fork-only probe. It runs on push to probe/** and samples TIME_WAIT on Windows for 3.11–3.15 with -n auto, plus 3.14 and 3.15 with -n0.

Checked locally on Linux: the full suite passes with -n 4 and serially. No test leaves a task or timer on the shared loop. A fixed shuffled order fails the same 24 order-dependent tests with either loop scope.

🤖 Generated with Claude Code

ZeliardM and others added 2 commits November 6, 2026 12:48
Every event loop opens a socketpair for its self-pipe, and on Windows
that is a loopback TCP connection that leaves a port in TIME_WAIT when
closed. With a loop per test, a full run opens about 26,000 of them and
can use up the dynamic port range.

With one loop per session the suite opens about 100, so the Windows-only
SO_LINGER fixture is no longer needed. No test leaves a task or timer
on the shared loop, and shuffled runs fail the same tests as with a loop
per test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stream)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ZeliardM

ZeliardM commented Nov 6, 2026

Copy link
Copy Markdown
Owner Author

Test finished: the change is now in python-kasa#1839.

@ZeliardM ZeliardM closed this Nov 6, 2026
@ZeliardM
ZeliardM deleted the probe/session-loop branch November 6, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant