I have the below, which is able to display the value in Shiny after some time:
library(promises)
library(future)
plan(multicore)
f_dots <- function() {
f <- future({
s <- rnorm(1000000000)
mean(s)
}) %plan% multiprocess
while (!resolved(f)) {
cat("...")
}
cat("\n")
value(f)
}
output$RowsRuns2 <- renderUI({
HTML(f_dots())
})
However, when I replaced the f_dots function with my long running process as below:
f_dots <- function() {
f <- future({
get_raw_dataset(5001,'2020-01-01','2020-11-01')
}) %plan% multicore
while (!resolved(f)) {
value("...")
}
cat("\n")
value(f)[[1]]
}
it does not display any value in the Shiny output, although I tested on the Console itself, it does has the value:
> f_dots <- function() {
+ f <- future({
+ get_raw_dataset(5001,'2020-01-01','2020-11-01')
+ }) %plan% multicore
+
+ while (!resolved(f)) {
+ value("...")
+ }
+ cat("\n")
+
+ value(f)[[1]]
+ }
> HTML(f_dots())
63
The output from get_raw_dataset is a list, that is why I am having value(f)[[1]]
Do you have any idea what went wrong? Is this issue comes from Shiny itself? That get_raw_dataset is a function generated from the reticulate package (which brings in the python function into R). But I suppose it is not that issue, as it is able to generate its output as shown above.
Main question is why is it able to show its output at the R terminal console, but it is not able to display inside Shiny.