Closed aronlindberg closed 9 years ago
I don't think it's the role of rgithub
to perform rate-limiting. But one thing it could do is simply refuse to issue the request (and throw an exception, for example) if we've used our rate limits.
So your solution seems to be just fine, but I don't think the current state of rgithub
is bad enough for it to be an issue.
It would be helpful to have automatic management of rate limits.
I don't know how to implement this across the board, but I have some ideas for a "manual" solution.
$x-ratelimit-remaining
tracks how many requests you have left and$x-ratelimit-reset
is a timestamp formatted as seconds-since-the-epoch. I suppose that if the query is wrapped in a loop one can check when$x-ratelimit-remaining
is approaching zero, and then simply implementSys.sleep()
until the rate limit has been reset, and then resume the looping of your queries.For example:
if (downloaded_api_response$headers$
x-ratelimit-remaining< 5)
Sys.sleep(as.integer(files$headers$
x-ratelimit-reset)-as.POSIXct( Sys.time() ) %>% as.integer())
else
do stuff
What do you think of this (as a manual solution)?