Folks
I have a working Shiny app which runs a number of long running database queries. I successfully use future_promise() to run those queries in a background process. In one of these background processes, I also give the option to generate output to a PPTX file via the officer package.
In order to pass the output of pptx <- read_pptx() between processes, I first created variable pptx as global. While this worked, it limited multi-user ability.
I've attempted to store the pptx variable in a file via saveRDS() (as well as save()), which seems to work. In the background process, I read the pptx variable back in via readRDS() (and I've tried load() as well). This also seems to work, but when I attempt to pass the now local pptx variable to an officer function, the function fails with "external pointer is not valid".
A slimmed down example of this issue would look like:
pptx <- read_pptx(path = "PreRenewal-template.pptx")
saveRDS(pptx, file="_pptx.rds")
observeEvent(
input$pptButton,
{
pr_pptx <- future_promise({
pptx <- readRDS(pptx, file="_pptx.rds")
pptx <- on_slide(pptx, index=1) # this line will fail with "external pointer is not valid"
}) %...>%
{
print("pptx serialized to RDS file")
} %...!%
{
print("pptx errored while serializing to RDS file")
}
})
Any clues as to why saveRDS/readRDS is not behaving with the pptx variable?
Thx!
Joe