Learn R Programming

reproducible (version 1.1.1)

retry: A wrapper around try that retries on failure

Description

This is useful for functions that are "flaky", such as curl, which may fail for unknown reasons that do not persist.

Usage

retry(
  expr,
  envir = parent.frame(),
  retries = 5,
  exponentialDecayBase = 1.3,
  silent = TRUE
)

Arguments

expr

Quoted expression to run, i.e., quote(...)

envir

The environment in which to evaluate the quoted expression, default to parent.frame(1)

retries

Numeric. The maximum number of retries.

exponentialDecayBase

Numeric > 1.0. The delay between successive retries will be runif(1, min = 0, max = exponentialDecayBase ^ i - 1) where i is the retry number (i.e., follows seq_len(retries))

silent

Logical indicating whether to try silently.

Details

Based on https://github.com/jennybc/googlesheets/issues/219#issuecomment-195218525.