When mclapply(X, FUN)
encounters errors for some of the values of X
, the errors propagate to some (but not all) of the other values of X
:
require(parallel)
test <- function(x) if(x == 3) stop() else x
mclapply(1:3, test, mc.cores = 2)
#[[1]]
#[1] "Error in FUN(c(1L, 3L)[[2L]], ...[cut]
#
#[[2]]
#[1] 2
#
#[[3]]
#[1] "Error in FUN(c(1L, 3L)[[2L]], ... [cut]
#Warning message:
#In mclapply(1:3, test, mc.cores = 2) :
# scheduled core 1 encountered error in user code, all values of the job will be affected
How can I stop this happening?