Shiny Async Save to SQL DB on RStudio Pro and RStudio Connect

Hi,

Im looking for a way to asynchronously save data to a SQL database from Shiny apps hosted on RStudio Connect (developed in RStudio Pro). Right now these saves can take a while and are blocking which creates an issue for our users. Since the saves are usually data collection for the developer we dont necessarily need to make the user wait for them to finish.

I wanted to ask the following:
(1) is there an existing solution out there for doing this on RStudio Connect behind Shiny apps and on RStudio Pro as Im developing these apps?
(2) Im having an issue getting the code below to run on RStudio Pro. It appears that RStudio Pro endlessly creates or restarts the R process when using the "future" library to change the plan to "multiprocess". Does any one have an idea on why this would be happening?

Any help or advice would be greatly appreciated! Below is a Minimum Example to show what RStudio Pro seems to have issues with (comment shows which line loops endlessly and ends up locking my RStudio Pro account.

require(promises)
require(future)

## Resources
# https://stackoverflow.com/questions/41057849/run-asynchronous-function-in-r
# https://stackoverflow.com/questions/57694226/r-shiny-promise-future-blocks-process

plan(multiprocess) ## This is where RStudio Pro seems to have issues. I never get to the next line because of this.

long_runner <- function(x){
  print("Running")
  Sys.sleep(5)
  return(x)
}

p1 <- promise(long_runner("test"))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.