Learn R Programming

statnet.common (version 4.4.1)

forkTimeout: Evaluate an R expression with a hard time limit by forking a process

Description

This function uses

Usage

forkTimeout(
  expr,
  timeout,
  unsupported = c("warning", "error", "message", "silent"),
  onTimeout = NULL
)

Arguments

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

onTimeout

Value to be returned on time-out.

Value

Result of evaluating expr if completed, onTimeout otherwise.

Examples

Run this code
# NOT RUN {
forkTimeout({Sys.sleep(1); TRUE}, 2) # TRUE
forkTimeout({Sys.sleep(1); TRUE}, 0.5) # NULL (except on Windows)
# }

Run the code above in your browser using DataLab