retry: Retry expression with exponential backoff

Description Usage Arguments Details Value Examples

View source: R/retry.r

Description

Attempts the expression in expr up to the number of tries specified in max_attempts. Each time a failure results, the functions sleeps for a random amount of time before re-attempting the expression. The upper bound of the backoff increases exponentially after each failure.

Usage

1
retry(expr, silent = FALSE, max_attempts = 10, verbose = FALSE)

Arguments

expr

an R expression to try.

silent

logical: should the report of error messages be suppressed?

verbose

logical: Should detailed messages be reported regarding each attempt? Default: no.

max_tries

the maximum number of times to attempt the expression expr

Details

For details on exponential backoff, see: http://en.wikipedia.org/wiki/Exponential_backoff

Value

the value of the expression in expr. If the final attempt was a failure, the objected returned will be of class try-error".

Examples

1
2
# Silly example that will never succeed.
retry(log("a"), verbose=TRUE, max_attempts=5)

ramhiser/pocketknife documentation built on May 26, 2019, 10:11 p.m.