fscaret (version 0.8.4)

timeout: timeout

Description

This function limits the cpu time spent on single model fitting. It simply sets the killing process of itself to sleep for chosen number of seconds. Shouldn't be called from R console.

Usage

timeout(expr, seconds, my.pid)

Arguments

expr
Expression to be time limited
seconds
Number of seconds
my.pid
Process PID

Examples

Run this code
## The function is currently defined as
function (expr, seconds, my.pid) 
{
    killer.pid <- system(intern = TRUE, paste("(sleep", seconds, 
        "; kill -9", my.pid, ")>/dev/null&
 echo $!", sep = ""))
    on.exit(system(paste("kill", killer.pid, "> /dev/null 2>&1", 
        sep = "")))
    withCallingHandlers(expr, interrupt = function(...) {
        stop("Timedout", call. = FALSE)
    })
  }

Run the code above in your browser using DataCamp Workspace