Skip to content

gh-81207: Handle socketserver timeouts at the deadline - #159628

Open
LarryHu0217 wants to merge 1 commit into
python:mainfrom
LarryHu0217:codex/socketserver-deadline-81207
Open

LarryHu0217 wants to merge 1 commit into
python:mainfrom
LarryHu0217:codex/socketserver-deadline-81207

Conversation

@LarryHu0217

@LarryHu0217 LarryHu0217 commented Oct 17, 2026 •

Copy link
Copy Markdown

Fixes #81207.

After an empty selector result, BaseServer.handle_request() now treats a remaining timeout of zero as expired. This prevents repeated zero-timeout polls when the clock stays exactly at the deadline. Retries before the deadline and ready requests with a zero timeout keep their existing behavior.

Adds deterministic clock/selector regression tests for zero, exact, early-wakeup and elapsed deadlines, a ready-request control, and a Library NEWS entry.

Validated on macOS arm64 using the existing --with-pydebug configuration at e5ef47e94f7c9d970ad98e2c33870ccc3b04dc5c:

  • make -j2
  • Both new regression methods: pass. Against unchanged upstream source in the rebuilt interpreter, three timeout subcases fail as expected.
  • ./python.exe -B -m test -u network test_socketserver: 30 tests, success.
  • ./python.exe -B -m test -v -u network,cpu,walltime test_selectors test_httpservers test_xmlrpc: 318 tests, 50 standard platform/FD-limit skips, no failures.
  • ./python.exe -B -m test -u network -R 3:3 -m 'test_handle_request*' test_socketserver: pass.
  • Unmodified Tools/patchcheck/patchcheck.py, scoped ruff check --no-fix --no-cache (0.15.22), and git diff --check: pass.

The entire CPython test suite was not run locally.

Treat an empty selector result at the deadline as a timeout instead of polling again with zero remaining time. Cover exact and elapsed deadlines, early wakeups, and ready requests with deterministic clock and selector tests.
@python-cla-bot

python-cla-bot Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@StanFromIreland

Copy link
Copy Markdown
Member

We can't review until you sign the CLA.

@picnixz
picnixz marked this pull request as ready for review October 17, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

socketserver: BaseServer.handle_request() infinite loop

2 participants