Repository navigation
feat: add exponential backoff for rate limit handling - #9
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements exponential backoff retry logic to handle HTTP 429 (Too Many Requests) errors from the Hell Divers 2 API, addressing rate limit violations during data collection cycles.
Key Changes:
- Introduced centralized
_fetch_with_backoff()method with exponential backoff (2s → 4s → 8s → 16s → 32s over 5 retries) - Refactored all 10 scraper methods to use the new backoff handler
- Added type safety checks with
isinstance()for list-returning endpoints
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.
Overview
Implements exponential backoff retry logic to handle HTTP 429 (Too Many Requests) errors from the Hell Divers 2 API.
Problem
The data collector was hitting rate limit errors (429) on dispatches and other endpoints during collection cycles. The original 2-second delay between requests wasn't sufficient for the 5 requests/10 seconds API limit.
Solution
_fetch_with_backoff()method with exponential backoff on 429 errorsChanges
src/scraper.py: Refactored all HTTP requests to use centralized backoff handlerTesting
Related Issues
Fixes issue where collection cycle fails with "429 Client Error: Too Many Requests"