exponential_backoff_retry: Retry a Function With Exponential Backoff

Description Usage Arguments Value Examples

View source: R/utils.R

Description

This function is an internal helper that will retry a function will exponential wait times in case there are issues with the API

Usage

1
exponential_backoff_retry(expr, n = 5, verbose = FALSE)

Arguments

expr

an expression to be evaluated with exponential backoff

n

an integer or number indicating the number of times to execute the function before completely failing

verbose

a logical indicating whether to print messages when invoking the retry attempts

Value

the result of the evaluated expression

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## Not run: 
# use with an API call that you can't afford to error because of intermittent uptime
myFun <- function(){
 x <- runif(1)
 if(x < .6){
   stop('less than 3/5')
 }
 return(x)
}
exponential_backoff_retry(expr = myFun(), verbose = TRUE, n = 5)

## End(Not run)

ReportMort/googlesites documentation built on May 6, 2019, 10:12 a.m.