Skip to content

Re-enable forked processing in RStudio Jobs and RStudio Terminal? #316

@HenrikBengtsson

Description

@HenrikBengtsson

@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

  1. Could someone check how to detect whether R via an RStudio Job or not?

  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions