Displaying 1 result from an estimated 1 matches for "timeout_upper".
2019 May 22
1
make running on.exit expr uninterruptible
...onsider:
f <- function() {
suspendInterrupts({
on.exit(suspendInterrupts(cntr_on.exit <<- cntr_on.exit + 1L))
cntr_f <<- cntr_f + 1L
})
TRUE
}
It is possible to interrupt this function such that cntr_f is incremented while cntr_on.exit is not (you might need to adjust timeout_upper to trigger the error on your machine):
timeout_upper <- 0.00001
repeat {
cntr_f <- 0L
cntr_on.exit <- 0L
# timeout code borrowed from R.utils::withTimeout but with setTimeLimit()
# (correctly) place inside tryCatch (otherwise timeout can occur before it can
# be caught) and w...