Sys.sleep() global?


#1

If I call Sys.sleep() in a Shiny app that’s on server pro, will this send the entire shiny server to sleep, or just the specific session? I’m trying to pause for a second in between functions. The sequence is:

  1. Click on a button.
  2. Update progress bar, and start creating file locally.
  3. Save file locally.
  4. Update progress bar again.
  5. Set sys.sleep(2) so reader has time to read progress bar.
  6. Finish process.

#2

It won’t be the entire Shiny Server that’s paused, but any sessions that are connected to that particular R process are going to have to wait. For Shiny Server Pro, you can use the utilization_scheduler directive in your shiny-server.conf file to specify how many or few browser sessions are allowed to connect to a single R process before SSP spawns a new R process. If you have any questions or issues getting this working, you can email support@rstudio.com.

In the next version of Shiny there will be support for asynchronous operations, which will give you finer grained control over this sort of thing, at the cost of making your application code more complicated (asynchronous logic has a different syntax than regular R code).


#3

Thanks Joe! And if we were to use debounce/throttle, does that similarly apply?