Keeps trying until the function's deferred value resolves without error, or times tries have been performed.

async_retry(task, times, ...)

Arguments

task

An asynchronous function.

times

Number of tries.

...

Arguments to pass to task.

Value

Deferred value for the operation with retries.

Examples

httpbin <- webfakes::new_app_process(webfakes::httpbin_app())
## Try a download at most 5 times
afun <- async(function() {
  async_retry(
    function() http_get(httpbin$url("/get")),
    times = 5
  )$then(function(x) x$status_code)
})

synchronise(afun())
#> [1] 200