How can I print messages to console when using `future_lapply()`?

Viewed 382

I am running a function in parallel in R using future_lapply(), but I want to print a message to the R console.

I have something like this:

library(future.apply)

plan(multisession, workers = 2)
future_lapply(1:12, function(idx) {
  Sys.sleep(5)
  print(paste0( idx, " completed."))
})

But the output of each print() is only displayed when all the processes end. How can I output them as soon as they are generated?

0 Answers
Related