The hold()
function is a helper to turn a promises::promise()
in a
synchronous value: the R session awaits the fulfillment of the promise
and returns the value of the fulfilled promise. An error is thrown if the
promise is rejected or a timeout expires. This is a wrapper around
later::run_now()
.
hold( x, timeout = 30, msg = paste("The asynchronous job has not finished in the delay of", timeout, "seconds.") )
x | A |
---|---|
timeout | Number scalar, timeout in seconds. An error is thrown if the promise is still pending when the delay expires. |
msg | Error message when the timeout expires. |
The value of the promise once resolved.
This function must not be used inside a function that returns a promise. Otherwise, this will lead to an infinite loop.