Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the withProgress is closed, the program still runs in the background. #3985

Open
bioinformzhang opened this issue Feb 29, 2024 · 3 comments

Comments

@bioinformzhang
Copy link

bioinformzhang commented Feb 29, 2024

When the withProgress is closed, the program still runs in the background. I don't know if it's a bug, if not can add this feature? this is a example in 《Mastering Shiny》.

library(shiny)
ui <- fluidPage(
    numericInput("steps", "How many steps?", 10),
    actionButton("go", "go"),
    textOutput("result")
)

server <- function(input, output, session) {
    data <- eventReactive(input$go, {
        withProgress(message = "Computing random number", {
            for (i in seq_len(input$steps)) {
                Sys.sleep(0.5)
                incProgress(1 / input$steps)
            }
            runif(1)
        })
    })
    
    output$result <- renderText(round(data(), 2))
}
shinyApp(ui, server)

Thanks!

@cpsievert
Copy link
Collaborator

cpsievert commented Feb 29, 2024

the program still runs in the background.

I'm not sure I understand what you're referring to here. The example appears to work as expected for me. Could you please be more precise about what you're observing and how you expect it to be different?

@gadenbuie
Copy link
Member

I think @bioinformzhang is wanting the task/process to be cancelled when the progress message is closed.

@bioinformzhang
Copy link
Author

bioinformzhang commented Mar 4, 2024

Yep, when I close the progress bar(message) in the lower right corner, the program is still running in the background, as shown in the example 0.85

When.the.withProgress.is.closed.the.program.still.runs.in.the.background.Issue.3985.rstudio_shiny.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants