Repository navigation
Apply the request timeout to the server lookup - #1569
Merged
Merged
Conversation
The DNS SRV lookup for the API server ran before the request timeout started, so a DNS server that did not answer could stall a request far beyond request_timeout, on every retry. Look up the server inside the same timeout, so it is handled and retried like any other slow request.
4 of 11 tasks
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.
Breaking change
None.
request_timeoutnow covers the server lookup and the HTTP request together, instead of only the HTTP request. The lookup only happens on the first request and after a failure, since the server is cached in between.Proposed change
Found in a review of the library. The DNS SRV lookup that picks an API server ran before the
asyncio.timeoutblock in_request_once(), sorequest_timeoutdid not apply to it. With a DNS server that does not answer, a request waited on the resolver's own timeouts instead, and did so again on every one of the five attempts. Reproduced: a lookup of 0.3 seconds succeeded with arequest_timeoutof 0.01 seconds.The lookup now runs inside the same timeout as the request. A lookup that runs out of time is handled like any other slow request: the client raises a
RadioBrowserConnectionTimeoutErrorand retries.The new test uses a lookup that never answers; it hangs forever without this change.
Type of change
Additional information
Checklist
poetry run pytestpasses locally. A pull request cannot be merged unless CI is green.poetry run prek run --all-filespasses (lint, format, and type checks).