Learn R Programming

FastRet (version 1.3.0)

withTimeout: Execute an expression with a timeout

Description

Execute an expression with a timeout

Usage

withTimeout(expr, timeout = 2)

Value

The result of the expression

Arguments

expr

The expression to execute

timeout

The timeout in seconds. Default is 2.

Examples

Run this code
withTimeout(
     cat("This works\n"),
     timeout = 0.2
)
try(silent = TRUE, withTimeout(
    expr = {Sys.sleep(0.2); cat("This fails\n")},
    timeout = 0.1
))

Run the code above in your browser using DataLab