Adds code to deal with rate limits imposed by Product Hunt API#4
Open
luizvbo wants to merge 1 commit intoanatg:masterfrom
luizvbo:rate_limit_code
Open
Adds code to deal with rate limits imposed by Product Hunt API#4luizvbo wants to merge 1 commit intoanatg:masterfrom luizvbo:rate_limit_code
luizvbo wants to merge 1 commit intoanatg:masterfrom
luizvbo:rate_limit_code
Conversation
Each API response includes 3 rate limit headers. You can use these headers to check your current rate limit status. - X-Rate-Limit-Limit: Your applications limit for the 15 minute period - X-Rate-Limit-Remaining: Remaining allowed requests for the reset period - X-Rate-Limit-Reset: Seconds until the rate limit is reset The methods `_update_time_limits` is called at each request and updates three new atributes of the class responsible for keeping track of these three limits. The method `get_rate_limits` is used to acess these values and `wait_if_no_rate_limit_remaining` wait the limit to be restabilished before making a new request.
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.
Each API response includes 3 rate limit headers. You can use these
headers to check your current rate limit status.
period
The methods
_update_time_limitsis called at each request and updatesthree new atributes of the class responsible for keeping track of these
three limits. The method
get_rate_limitsis used to acess these valuesand
wait_if_no_rate_limit_remainingwait the limit to be restabilishedbefore making a new request.