async_retry: Retry an asynchronous function a number of times

View source: R/retry.R

async_retryR Documentation

Retry an asynchronous function a number of times

Description

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

Usage

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.

See Also

Other async control flow: async_backoff(), async_reflect(), async_retryable(), async_sequence(), async_try_each(), async_until(), async_whilst()

Examples


## Try a download at most 5 times
afun <- async(function() {
  async_retry(
    function() http_get("https://eu.httpbin.org"),
    times = 5
  )$then(function(x) x$status_code)
})

synchronise(afun())


r-lib/async documentation built on March 24, 2024, 6:20 p.m.