Is it possible to stop execution of R code inside shiny (without stopping the shiny process)?

2,158 views
Skip to first unread message

Dean Attali

unread,
Jun 4, 2015, 6:59:29 PM6/4/15
to shiny-...@googlegroups.com
(x-post from SO because of 0 answers)

Let's say I have a shiny app that has a function that can take a long time to run. Is it possible to have a "stop" button that tells R to stop the long-running call, without having to stop the app?

Example of what I mean:

analyze <- function() {
  lapply
(1:5, function(x) { cat(x); Sys.sleep(1) })
}

runApp
(shinyApp(
  ui
= fluidPage(
    actionButton
("analyze", "Analyze", class = "btn-primary"),
    actionButton
("stop", "Stop")
 
),
  server
= function(input, output, session) {
    observeEvent
(input$analyze, {
      analyze
()
   
})
    observeEvent
(input$stop, {
     
# stop the slow analyze() function
   
})
 
}
))


Frédéric Moser

unread,
Dec 29, 2015, 2:41:15 PM12/29/15
to Shiny - Web Framework for R
I've posted something on SO about this :

John Luis

unread,
Feb 6, 2016, 12:12:37 AM2/6/16
to Shiny - Web Framework for R
I have this exact same need, so reposting Dean's old question.  I want to give the user a Stop button so they can stop a call midway if it's taking long.  

I tried stop() but it doesn't interrupt the function that's running.

Thoughts?

Thanks!

Joe Cheng

unread,
Feb 6, 2016, 12:17:35 AM2/6/16
to John Luis, Shiny - Web Framework for R
It's not possible right now, but last week I would've told you it would never be possible, whereas now I can think of a way to possibly implement this once we have done our next round of changes on httpuv. No promises though and in the meantime I can't think of any workaround.
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/e4171155-b44d-4bfb-9861-d43d3b646b79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

John Taveras

unread,
Feb 8, 2016, 9:34:21 AM2/8/16
to Joe Cheng, Shiny - Web Framework for R

Sounds great! Fingers crossed that you find a way.

Sent from my mobile device

hol...@geocf.com

unread,
Feb 8, 2016, 1:31:06 PM2/8/16
to Shiny - Web Framework for R, j...@rstudio.com
This would definitely be useful.

Chris

Nicholas Crookston

unread,
Mar 7, 2016, 6:47:39 PM3/7/16
to Shiny - Web Framework for R, j...@rstudio.com
This is related to topic: https://groups.google.com/forum/#!topic/shiny-discuss/aZqOxOdvBxU

I could really use this as well.

Katie Leap

unread,
May 12, 2016, 7:55:16 PM5/12/16
to Shiny - Web Framework for R, j...@rstudio.com
This would also be very useful to me.

Pedro Carvalho

unread,
Feb 6, 2017, 11:15:43 AM2/6/17
to Shiny - Web Framework for R, j...@rstudio.com
Has this been implemented? Are there plans to?

Joe Cheng [RStudio]

unread,
Feb 7, 2017, 2:24:53 AM2/7/17
to Shiny - Web Framework for R, j...@rstudio.com
There are plans to implement something like this for specific long-running computations, yes. Not so much for general "stop whatever you're doing", though. As usual I don't have timeframes to share but we're hoping to look at this next, after our current push on automated testing.

Daniel Cañueto

unread,
Apr 8, 2017, 8:27:45 AM4/8/17
to Shiny - Web Framework for R, j...@rstudio.com
I would also be definitely interested.

Adrian Dușa

unread,
Jan 7, 2018, 6:34:36 AM1/7/18
to Shiny - Web Framework for R
I would also be interested, if this has been pushed already.
Adrian

Dylan Cissou

unread,
Feb 19, 2018, 10:16:31 AM2/19/18
to Shiny - Web Framework for R
I would also be very much interested.

Naim Al Mahi

unread,
Feb 25, 2018, 2:58:14 PM2/25/18
to Shiny - Web Framework for R
Any update on this issue? 


On Thursday, June 4, 2015 at 6:59:29 PM UTC-4, Dean Attali wrote:
Reply all
Reply to author
Forward
0 new messages