timeout
From fscaret v0.8.5.6
by Jakub Szlek
timeout
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. The function is not used under Windows OS.
Usage
timeout(expr, seconds, my.pid)
Arguments
- expr
- Expression to be time limited
- seconds
- Number of seconds
- my.pid
- Process PID
Examples
## 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)
})
}
Community examples
Looks like there are no examples yet.