feat: Use Unit timeout value on request's timeout #292
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.
Hey, team!
We've had some issues in the past that we linked to outage/instability on the Unit API's side - we saw on a couple occasions our async workers getting "locked", we looked into what was happening and, basically, during these API outage/unstable periods, our API requests were simply hanging without ever failing due to timeouts. (Link to Zendesk ID)
This does check out, the
Configuration
object has atimeout
parameter, but that is only used on thebackoff.on_predicate(max_time)
, and the predicate truly only applies to "proper" responses received from the server, so if a request takes forever, thismax_time
won't ever be used.The
requests
lib does not have a default timeout (seen here), and I believe it's best practice to have this set - to avoid having requests hanging.The implementation here is simply passing in
timeout=self.configuration.get_timeout()
to the requests on theBaseResource
. The caveat: the timeout will now raise arequests.Exception.ConnectTimeout/ReadTimeout
, and I'm not sure if y'all want to handle this actively, or if it's fair game to just let this exception bubble up.