0

Can we create multiple sessions in R language . I am not using Rstudio or shiny app . I am just integrating R and python using pip module pypeR. I cannot see any R code where i can learn to create session. My requirement is to create a new session for every R request from python. Because whenever there are two requests to R at the same time my server gets blocked.

Also i have used "pypeR" module to integrate R with python.

import pyper
r=pyper.R(RCMD="/usr/bin/R")
path2script =  path of my script file
output = r.run("source('"+path2script+"')")

I am a newbie in R as i have worked more in python.I have searched a lot about this issue and it seems to me that R works only in single session when called as a script through python.

Any help would be appreciated.

  • 2
    It would help a lot if your question included a small reproducible example containing the problem that you are facing. Currently you are "looking for recommendations" which is off-topic. Adding the example will also increase it's usefulness for others in the future with a similar question. – Oliver Mar 15 '21 at 14:01
  • @Oliver i am actually looking for suggestion as i am not sure that we can create multiple sessions in R. I want to know if it is possible or not. I have seen that Rstudio & shiny supports multiple sessions but R alone i have no idea about. – Manibha Jain Mar 16 '21 at 06:19
  • Both R and python are "unithreaded" programs by nature. Python does have some threading possibility, while R highly discourages using threads. Instead you would use sessions in the `parallel` package, similar to opening multiple terminals and opening an R session in each.. Have you tried going parallel and executing `r = pyper.R(---)` from each python session? I am not familiar with the package but that would be my first thought. – Oliver Mar 16 '21 at 07:44
  • As a side note that would be what you do if you were programming in R, eg. using `library(parallel); nc <- detectCores() - 1; cl <- makeCluster(nc); res <- parLapply(cl, STUFF_TO_ITERATE_OVER, FUNCTION_TO_APPLY)` or one of the many similar parallel methods available in R. – Oliver Mar 16 '21 at 07:51
  • @Oliver my actual problem is this https://stackoverflow.com/questions/66583670/pyper-suddenly-stops-working-when-two-or-more-users-use-it . I dont know if this is actually an R session issue but i think it is. – Manibha Jain Mar 16 '21 at 08:26

0 Answers0