-
Notifications
You must be signed in to change notification settings - Fork 80
Open
Description
Hi,
I am not sure if I am doing something wrong or if I just don't understand how req_throttle()
works. But my expectation was that there would only be 1 request per minute based on this configuration. But what happens is that requests are made as fast as possible until the rate limit is hit, even when no tokens are available via throttle_status()
. Is this a bug or am I doing something wrong?
library(httr2)
foo <- function() {
x <-
request("https://eutils.ncbi.nlm.nih.gov/entrez/eutils") |>
req_url_path_append("esearch.fcgi") |>
req_url_query(
db = 'pubmed',
term = 'Richard Feynman[au]',
retmode = 'json'
) |>
req_throttle(capacity = 1, fill_time_s = 60) |>
req_perform() |>
resp_body_json()
print(throttle_status())
x
}
replicate(100, foo())
#> realm tokens to_wait
#> 1 eutils.ncbi.nlm.nih.gov 0 60
#> realm tokens to_wait
#> 1 eutils.ncbi.nlm.nih.gov 0 59
#> realm tokens to_wait
#> 1 eutils.ncbi.nlm.nih.gov 0 60
#> Error in `req_perform()`:
#> ! HTTP 429 Too Many Requests.
Metadata
Metadata
Assignees
Labels
No labels