HenrikBengtsson/future

makeClusterPSOCK: Be agile to parallel:::.slaveRSOCK() -> parallel:::.workRSOCK() name change in R (>= 4.1.0)

Closed this issue · 1 comments

For troubleshooting, it would be useful if makeClusterPSOCK()/makeNodePSOCK() would infer the R version of the worker's Rscript (argument rscript) before launching the R worker. This would have helped in for instance Issue #143 and #351

Another reason to programmatically infer the R version of each worker is today's update in R-devel ("4.1.0") where parallel:::.slaveRSOCK() is being renamed to parallel:::.workRSOCK(), which will cause problems when the main R session and the PSOCK workers run different versions of R(*). If we know each worker's R version, we can launch either parallel:::.slaveRSOCK() or parallel:::.workRSOCK() conditionally.

(*) I've emailed R Core (2020-07-06 @ 19:20 UTC) about this since it is a problem that is likely to affect many 'parallel' use cases. My recommendation is to support both and phase out parallel:::.slaveRSOCK() over a few release cycles.

makeClusterPSOCK() should now be agile to whatever R version each worker runs;

future/R/makeClusterPSOCK.R

Lines 677 to 682 in 76fb941

## .{slave,work}RSOCK() command already specified?
if (!any(grepl("parallel:::[.](slave|work)RSOCK[(][)]", rscript_args))) {
## In R (>= 4.1., parallel:::.slaveRSOCK() was renamed .workRSOCK()
cmd <- "workRSOCK <- tryCatch(parallel:::.slaveRSOCK, error=function(e) parallel:::.workRSOCK); workRSOCK()"
rscript_args <- c(rscript_args, "-e", shQuote(cmd))
}