This function attempts to execute code multiple times with random delays between attempts. It's particularly useful for handling transient failures in operations that may succeed on subsequent attempts, such as network requests or file operations.
try_again(
x,
times = 2,
delay_seconds_min = 5,
delay_seconds_max = 10,
verbose = FALSE
)The code to execute (as an expression)
Integer, the maximum number of attempts to make. Defaults to 2
Numeric, the minimum delay in seconds between attempts. Defaults to 5
Numeric, the maximum delay in seconds between attempts. Defaults to 10
Logical, whether to show progress information. Defaults to FALSE
TRUE invisibly if successful, otherwise throws an error with the last
error message
The function is adapted from the try_again function in the testthat package,
but with additional features for controlling retry behavior and verbosity.