async_backoff | R Documentation |
Keeps trying until the function's deferred value resolves without
error, or times
tries have been performed, or time_limit
seconds
have passed since the start of the first try.
async_backoff(
task,
...,
.args = list(),
times = Inf,
time_limit = Inf,
custom_backoff = NULL,
on_progress = NULL,
progress_data = NULL
)
task |
An asynchronous function. |
... |
Arguments to pass to |
.args |
More arguments to pass to |
times |
Maximum number of tries. |
time_limit |
Maximum number of seconds to try. |
custom_backoff |
If not |
on_progress |
Callback function for a progress bar. Retries are
announced here, if not
|
progress_data |
|
Note that all unnamed arguments are passed to task
.
Deferred value for the operation with retries.
Other async control flow:
async_reflect()
,
async_retry()
,
async_retryable()
,
async_sequence()
,
async_try_each()
,
async_until()
,
async_whilst()
afun <- function() {
wait_100_ms <- function(i) 0.1
async_backoff(
function() if (runif(1) < 0.8) stop("nope") else "yes!",
times = 5,
custom_backoff = wait_100_ms
)
}
# There is a slight chance that it fails
tryCatch(synchronise(afun()), error = function(e) e)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.