0

I'm struggling with a parallel R computation (on an Ubuntu 16.04 server, R version 3.6). I'm trying to

1) source an external script as a child process (with mcparallel)

2) and display the output from the console on the frontend of my app with ShinyJS.

Unfortunately, if the process works as planned, nothing is output in the console (stderr or stdout), even with the argument "silent = FALSE".

My first question : Is there a way to force it with mcparallel ?

Alternative : How could it be achieved alternaltively with MakeCluster ? I read that the argument outfile = "" is meant to send output to the console. (ref : How can I `print` or `cat` when using parallel)

My second question : How would you advise to send said console output to the Shiny front end with Shinyjs ? I know it should be done on the synchronous Shiny side but i'm open to ideas to make it effective.

My code :

library(parallel)
library(tools)

# Child process

wrapper <- function(){ source("external-script.R", local = TRUE, echo = TRUE) }
Job1 <- mcparallel(wrapper())
result <- mccollect(Job1, wait = FALSE)

# Script works as planned but no output on the console

# After a while Kill it

Sys.sleep(60)
    pskill(Job1$pid)
François
  • 1
  • 1
  • Child processes don't send their stder or stdout stream to the main process. Your script needs to return a value that goes into `result`. Printing (or `cat`ing) should happen in the main process. – Roland May 13 '20 at 07:09
  • Hello Roland and thank you for your answer. So is there no any other solution to send stder to the main process ? Maybe with the processx library ? – François May 13 '20 at 07:15
  • I don't know but I strongly suggest that you don't follow that path and instead spend your time fixing the script. – Roland May 13 '20 at 11:52

0 Answers0