Skip to content

Add request timeouts#18

Open
massy-o wants to merge 1 commit into
bananaml:mainfrom
massy-o:codex/add-request-timeouts
Open

Add request timeouts#18
massy-o wants to merge 1 commit into
bananaml:mainfrom
massy-o:codex/add-request-timeouts

Conversation

@massy-o
Copy link
Copy Markdown

@massy-o massy-o commented May 14, 2026

Summary

  • add configurable request timeouts for Client and API calls
  • pass timeout through all requests calls
  • avoid mutating caller-provided headers when Client.call injects Banana headers

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

  • python3 -m unittest discover -s tests

Note: local test output includes urllib3's LibreSSL NotOpenSSLWarning on macOS Python 3.9, but the tests pass.

Comment thread banana_dev/client.py
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)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self-review: Copying the caller-provided headers keeps the timeout change from also mutating user-owned dictionaries when Banana auth headers are injected.

Comment thread banana_dev/client.py
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):
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant