I want to print debug info in an R future call to display information about how long some process (e.g. copying a file) takes.
future::plan(future::multisession)
copyInBackground <- function(from, to, overwrite = FALSE) {
future::future( {
jamba::printDebug("Starting ...")
fs::file_copy(path = path.expand(from),
new_path = path.expand(to),
overwrite = overwrite)
jamba::printDebug("Done.")
}
)
}
copyInBackground(from = "~/test.png", to = "H:/test/", overwrite = TRUE)
test <- copyInBackground(from = "~/test.png", to = "H:/test/", overwrite = TRUE)
future::value(test)
My expectation: The file is copied, and console output with timestamps from jamba::printDebug
.
I get some info on the MultisessionFuture if I call the function directly; and I get the timestamps only if I retrieve the value of the test
object.
Is there a way for the function to print output to the console immediately, or at least automatically once the job is finished?