@graemeblair wrote in #299 (comment):
Hi -- late to this, but wondering if supportsMulticore() should return TRUE when run within RStudio 1.2 "jobs" feature (and still FALSE when run interactively). As I understand it, when code is run through jobs it is separated from the GUI interactions that complicate using plan(multicore) in RStudio run interactively. This would enable the same scripts that use plan(multicore) to be used in and out of RStudio with a bit less hassle.
I took the conservative approach and disabled forked processing anywhere in RStudio by testing for environment variable RSTUDIO.
It could be that it's only unsafe when running R via the RStudio Console (the "RStudio GUI"), but that it indeed works when running R via the RStudio Terminal (Tools -> Terminal -> New Terminal) or as an RStudio Job. I know one can distinguish RStudio Console from RStudio Terminal as:
is_rstudio_console <- function() {
(Sys.getenv("RSTUDIO") == "1") && !nzchar(Sys.getenv("RSTUDIO_TERM"))
}
is_rstudio_terminal <- function() {
(Sys.getenv("RSTUDIO") == "1") && nzchar(Sys.getenv("RSTUDIO_TERM"))
}
Source: https://github.com/HenrikBengtsson/startup/blob/0.12.0/R/is_rstudio.R
-
Could someone check how to detect whether R via an RStudio Job or not?
-
Then we also need to reach out to the RStudio GUI folks about forked processing in the above three cases of running R from RStudio.
@graemeblair wrote in #299 (comment):
I took the conservative approach and disabled forked processing anywhere in RStudio by testing for environment variable
RSTUDIO.It could be that it's only unsafe when running R via the RStudio Console (the "RStudio GUI"), but that it indeed works when running R via the RStudio Terminal (Tools -> Terminal -> New Terminal) or as an RStudio Job. I know one can distinguish RStudio Console from RStudio Terminal as:
Source: https://github.com/HenrikBengtsson/startup/blob/0.12.0/R/is_rstudio.R
Could someone check how to detect whether R via an RStudio Job or not?
Then we also need to reach out to the RStudio GUI folks about forked processing in the above three cases of running R from RStudio.