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)