feat: add configurable request timeout to the Creators API - #154
Merged
Conversation
Rebase of #151 onto master (7.0.0) with the adjustments raised in review: - Bump to 7.1.0 in pyproject.toml, docs/conf.py and CHANGELOG.md - Forward the timeout in list_feeds, get_feed, list_reports and get_report, added after the original branch was written - Apply the timeout to the async OAuth2 token refresh, which always used the 5 second default from httpx - Reject timeouts of zero or below with InvalidArgumentError instead of surfacing a validation error from the bundled SDK - Document that the sync token refresh is handled by the bundled SDK and is not covered by this value Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JvKfVvJqdCZnPfNaNP2fT5
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.
Supersedes #151. Same feature, rebased onto
master(7.0.0) and with the points raised while reviewing that PR applied. Original work by @YPCrumble, authorship preserved on the commit.What it does
Adds a
timeoutparameter toAmazonCreatorsApiandAsyncAmazonCreatorsApi, defaulting to 30 seconds, withNoneto wait indefinitely. The sync client previously had no timeout at all, so a stalled connection to Amazon could hold a worker forever; it now matches what the async client already did.Changes over #151
pyproject.toml,docs/conf.py,CHANGELOG.md). The original branch targeted 6.4.0, which conflicted after the 6.4.0 and 7.0.0 releases.list_feeds,get_feed,list_reportsandget_reportlanded after the original branch was written and were not forwarding_request_timeout, so the timeout applied to only half the methods.AsyncOAuth2TokenManagerbuilt itshttpx.AsyncClientwith no arguments, so token refresh always used the 5 second httpx default regardless of the configured value. It now takes the same timeout as the API requests.InvalidArgumentErrorat construction. Previously they reached the bundled SDK, where_request_timeoutis annotatedgt=0, and surfaced as a raw pydanticValidationErrorin the sync client while failing instantly in the async one.creatorsapi_python_sdkperforms with a barerequests.postand no timeout. The entry now says "API requests", and the README and usage guide state what the value does and does not cover.Known limitation
The sync token refresh remains unbounded. Fixing it means either patching the bundled SDK, which the repo otherwise keeps untouched, or giving the sync client its own token manager the way
amazon_creatorsapi.aioalready has. Left out of this PR deliberately — happy to follow up whichever way you prefer.Verification
uv run pre-commit run -apasses in full: ruff format, ruff check, mypy, the test suite and the version consistency check. 160 passed, 47 skipped (integration tests, no credentials), coverage 98.76% against the 98% floor.🤖 Generated with Claude Code
https://claude.ai/code/session_01JvKfVvJqdCZnPfNaNP2fT5
Generated by Claude Code