View source: R/misc.utilities.R
forkTimeout | R Documentation |
This function uses
parallel::mcparallel()
,
so the time limit is not
enforced on Windows. However, unlike functions using setTimeLimit()
, the time
limit is enforced even on native code.
forkTimeout(
expr,
timeout,
unsupported = c("warning", "error", "message", "silent"),
onTimeout = NULL
)
expr |
expression to be evaluated. |
timeout |
number of seconds to wait for the expression to evaluate. |
unsupported |
a character vector of length 1 specifying how to
handle a platform that does not support
Partial matching is used. |
onTimeout |
Value to be returned on time-out. |
Result of evaluating expr
if completed, onTimeout
otherwise.
onTimeout
can itself be an expression, so it is, for
example, possible to stop with an error by passing
onTimeout=stop()
.
Note that this function is not completely transparent: side-effects may behave in unexpected ways. In particular, RNG state will not be updated.
forkTimeout({Sys.sleep(1); TRUE}, 2) # TRUE
forkTimeout({Sys.sleep(1); TRUE}, 0.5) # NULL (except on Windows)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.