Make an asynchronous funcion retryable

async_retryable(task, times)

Arguments

task

An asynchronous function.

times

Number of tries.

Value

Asynchronous retryable function.

See also

Examples

# \donttest{
## Create a downloader that retries five times
http_get_5 <- async_retryable(http_get, times = 5)
ret <- synchronise(
  http_get_5("https://eu.httpbin.org/get?q=1")$
    then(function(x) rawToChar(x$content))
)
cat(ret)
#> {
#>   "args": {
#>     "q": "1"
#>   }, 
#>   "headers": {
#>     "Accept": "*/*", 
#>     "Accept-Encoding": "deflate, gzip, br, zstd", 
#>     "Host": "eu.httpbin.org", 
#>     "User-Agent": "R/4.5.1 R (4.5.1 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions", 
#>     "X-Amzn-Trace-Id": "Root=1-689f5c99-697d0f8c7ed5e50479f25ed3"
#>   }, 
#>   "origin": "172.174.167.21", 
#>   "url": "https://eu.httpbin.org/get?q=1"
#> }
# }