Skip to content

Do not hang forever if test server fails to start - #3775

Open
akx wants to merge 2 commits into
encode:masterfrom
akx:test-server-fix
Open

Do not hang forever if test server fails to start#3775
akx wants to merge 2 commits into
encode:masterfrom
akx:test-server-fix

Conversation

@akx

@akx akx commented Feb 24, 2026

Copy link
Copy Markdown

Summary

I was wondering why the test suite just hung forever, and finally with pytest tests/ -vvvx --log-cli-level=DEBUG -s I found that:

[Errno 48] error while attempting to bind on address ('127.0.0.1', 8000): [errno 48] address already in use

– yep, I was working on something else on port 8000 – and so, server.running never becomes True, and tests just hang.

This PR:

  • Makes sure errors from server.run() (in the secondary thread) are caught and propagated immediately to the controlling loop
  • Adds timeouts, so even if something even more unexpected happens, the suite will error out instead of hanging forever.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
    • No separate tests for testing the test fixture 😄
  • I've updated the documentation accordingly.
    • No user-facing or developer documentation changes needed. (Noting that port 8000 must not be in use is a separate thing to maybe document, I think...)

@akx
akx force-pushed the test-server-fix branch 4 times, most recently from 76054c5 to b7dd358 比较 February 24, 2026 14:03
@akx
akx force-pushed the test-server-fix branch from b7dd358 to 8a959d8 比较 February 24, 2026 14:06
@lovelydinosaur

Copy link
Copy Markdown
Member

@akx Thanks... I've shifted my development efforts over to this comprehensive redesign, due to it's significantly reduced complexity.

See also HTTPX 1.0 design proposal docs in progress.


For comparison...

$ pip install httpx --pre
Downloading httpx-1.0.dev3-py3-none-any.whl (34 kB)
Downloading certifi-2026.1.4-py3-none-any.whl (152 kB)
Installing collected packages: certifi, httpx
$ pip install httpx
Downloading httpx-0.28.1-py3-none-any.whl (73 kB)
Downloading httpcore-1.0.9-py3-none-any.whl (78 kB)
Downloading anyio-4.12.1-py3-none-any.whl (113 kB)
Downloading idna-3.11-py3-none-any.whl (71 kB)
Downloading certifi-2026.1.4-py3-none-any.whl (152 kB)
Downloading h11-0.16.0-py3-none-any.whl (37 kB)
Installing collected packages: idna, h11, certifi, httpcore, anyio, httpx
$ pip install requests
Downloading requests-2.32.5-py3-none-any.whl (64 kB)
Downloading certifi-2026.1.4-py3-none-any.whl (152 kB)
Downloading charset_normalizer-3.4.4-cp313-cp313-macosx_10_13_universal2.whl (208 kB)
Downloading idna-3.11-py3-none-any.whl (71 kB)
Downloading urllib3-2.6.3-py3-none-any.whl (131 kB)
Installing collected packages: urllib3, idna, charset_normalizer, certifi, requests

注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

Development

Successfully merging this pull request may close these issues.

2 participants