Add request timeouts#18
Open
massy-o wants to merge 1 commit into
Open
Conversation
massy-o
commented
May 14, 2026
| headers['X-BANANA-REQUEST-ID'] = str(uuid4()) # we use the same uuid to track all retries | ||
| def call(self, route: str, json: dict = {}, headers: dict = {}, retry=True, retry_timeout = 300, request_timeout = None) -> Tuple[dict, dict]: | ||
| request_timeout = self.request_timeout if request_timeout is None else request_timeout | ||
| request_headers = dict(headers) |
Author
There was a problem hiding this comment.
Self-review: Copying the caller-provided headers keeps the timeout change from also mutating user-owned dictionaries when Banana auth headers are injected.
massy-o
commented
May 14, 2026
| class Client(): | ||
| "The Banana client class is for interacting with a specific project on Banana." | ||
| def __init__(self, api_key, url, verbosity = "DEBUG"): | ||
| def __init__(self, api_key, url, verbosity = "DEBUG", request_timeout = 300): |
Author
There was a problem hiding this comment.
Self-review: I kept the default at 300 seconds to line up with the existing retry_timeout and 5-minute timeout behavior, while still exposing request_timeout for callers that need a stricter bound.
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.
Summary
Why
Without a requests timeout, a stalled TCP/TLS connection can block indefinitely even though Client.call has a retry_timeout for retryable responses. The default is 300 seconds to match the existing retry window and the current 5-minute timeout guidance, while still allowing callers to override it.
Testing
Note: local test output includes urllib3's LibreSSL NotOpenSSLWarning on macOS Python 3.9, but the tests pass.