-
Notifications
You must be signed in to change notification settings - Fork 271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: add max_tries
to insistently()
#1049
Comments
Should probably mimic https://httr2.r-lib.org/reference/req_retry.html and provide both Would be useful to have this also as something you can use on a block of code, not just a function. |
There is already a library(purrr)
f <- local({
i <- 0
f <- function() {
i <- i + 1
if (i < 5) stop("Error")
i * 10
}
})
insistently(f)(1)
#> Error in `rate_sleep()`:
#> ! Request failed after 3 attempts.
#> Backtrace:
#> ▆
#> 1. └─insistently(f)(1)
#> 2. └─purrr::rate_sleep(rate, quiet = quiet)
#> 3. └─purrr:::stop_rate_excess(rate)
#> 4. └─cli::cli_abort(...)
#> 5. └─rlang::abort(...) Created on 2023-02-07 with reprex v2.0.2 I think we're now somewhat moving away from these adverbs (in hindsight their names seem too clever), but I'll probably implement |
Would be useful to have a {purrr} adverb that is similar to {httr2}'s
req_retry()
.I think(?) adding a
max_tries = Inf
(orNULL
default) param toinsistently()
wouldn't scope-creep too much, and letinsistently()
signal the (final) error once the retry count is exhausted.An motivating use case is wrapping a function that delegates to some system call (e.g. via {processx}) that itself might be making network calls with some potential failure rate. (My particular instance of this is with wrapping some AWS CLI calls, which can fail due to intermitent network issues.)
The text was updated successfully, but these errors were encountered: