Conversation
tests/test_uds.py slept 1.5s after spawning the server. On slower hosts the listener was not ready yet, so httpx hit ECONNREFUSED. Poll until the Unix socket accepts a connection (with a timeout) so fast machines return immediately and slow ones wait as needed. Fixes emmett-framework#855 Co-authored-by: MarkGus0 <MarkGus0@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
tests/test_uds.py spawned Granian and then slept a fixed 1.5 seconds before issuing HTTP requests over the Unix domain socket. On slower machines the UDS listener is often not accepting connections yet, so httpx fails with ConnectError. Fast machines paid the full 1.5s wait even when the socket was already ready.
This is a test-side race: the socket file can exist after bind while listen() has not completed.
Change
Replace asyncio.sleep(1.5) with _wait_until_uds_ready(), which polls until a connect to the UDS succeeds. It returns as soon as the listener accepts a connection, times out after 30 seconds with a clear error, and fails early if the server process exits before the socket is ready. A leftover socket file is treated as not ready (connect must succeed).
Helper coverage (no Granian process required):
Production server behavior is unchanged.
How tested
Fixes #855