Add rate limiting handling with automatic retry#156
Merged
Conversation
- Add FlickrRateLimitError exception for HTTP 429 responses - Implement automatic retry with exponential backoff on rate limit - Parse Retry-After header when available - Add configurable retry settings: set_retry_config(), get_retry_config() - Default: 3 retries, 1s base delay, 60s max delay The retry behavior can be configured or disabled: flickr_api.set_retry_config(max_retries=0) # Disable retries flickr_api.set_retry_config(max_retries=5, base_delay=2.0) When rate limited and retries are exhausted, raises FlickrRateLimitError with retry_after attribute containing the suggested wait time. Includes 17 new tests for rate limit handling. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
FlickrRateLimitErrorexception for HTTP 429 responsesRetry-Afterheader when availableset_retry_config()andget_retry_config()Usage
The retry behavior can be configured or disabled:
When rate limited and retries are exhausted, raises
FlickrRateLimitErrorwith:retry_after: Suggested wait time from server (or None)content: Error message contentBackground
Flickr returns HTTP 429 when the API rate limit (~3600 requests/hour) is exceeded. Previously this was not handled, causing JSON parsing to fail or return unexpected errors. Now the library automatically retries with backoff, or raises a clear exception when limits are exceeded.
Test plan
🤖 Generated with Claude Code