feat: default requests to a 30 second timeout - #601
Open
razor-x wants to merge 1 commit into
Open
Conversation
Requests had no timeout, so a hung connection blocked the caller indefinitely. niquests leaves `timeout` unset unless it is given. Pass a 30 second `timeout` to the niquests session, matching the API's own request timeout, and add a `timeout` option to `Seam` and `SeamMultiWorkspace` so callers can raise or lower it. The option takes the niquests forms: a number of seconds, a (connect, read) tuple, or None for no timeout. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XMgDauUA2R9u2THCHmMgv1
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.
Part of a four-SDK change adding a default HTTP timeout (javascript-http, ruby, csharp).
Problem
Requests had no timeout, so a hung connection blocked the caller indefinitely. niquests leaves
timeoutunset unless it is given.Changes
timeoutto the niquests session by default, matching the API's own request timeout.timeoutoption toSeam,SeamMultiWorkspace, and their factory methods.(connect, read)tuple, orNonefor no timeout.The session-level
timeoutis passed throughSession.__init__alongsideretries, which niquests requires for adapter-mounted options.Note that
timeout=Nonemeans no timeout here, following the niquests convention, rather than use the default asretries=Nonedoes. That asymmetry is deliberate —Noneis the only way niquests expresses "no timeout", and disabling the timeout should stay expressible.Behavior change
Requests that previously ran longer than 30 seconds will now raise
niquests.exceptions.Timeout. Thetimeoutoption is the opt-out.Testing
66 tests pass, 5 of them new in
test/timeout_test.py, including one that drives a socket server which accepts connections but never responds.blackis clean.Note for reviewers
Retries multiply the timeout, and this SDK's retry default is the steepest of the four.
DEFAULT_RETRIES = Retry()is urllib3's default oftotal=10, so a fully hung endpoint is now bounded at roughly 30s × 11 ≈ 5.5 minutes rather than forever. That is a large improvement over unbounded, but the retry count looks unintentional and is worth a separate look. I left retry behavior untouched here since the ask was timeouts.🤖 Generated with Claude Code
https://claude.ai/code/session_01XMgDauUA2R9u2THCHmMgv1
Generated by Claude Code