Skip to content

Computation continues after interruption of parallelised future workers in R #1086

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

Open
jfsalzmann opened this issue May 7, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jfsalzmann
Copy link

jfsalzmann commented May 7, 2025

Describe the bug
I noticed that when doing parallel sampling from multiple (possibly different) STAN models within future workers and cancelling the execution of the main R script (the R parent process - in my case, using Ctrl+C in CLI mode), the STAN models and the children R processes will continue running as ghost processes. Appearently, something in the signal chain does not work. My guess is that although the signalling chain works well on the future side (this doesn't occur when no STAN model is running), the children R processes cannot stop as long as its children processes (= STAN process) are not stopped. I may be wrong though and this might be a bug in the future or foreach package, too.

To Reproduce

library(cmdstanr)
library(foreach)
library(doFuture)
plan(multisession,workers = 2)

foreach(i=1:2, .options.future = list(seed = TRUE), .inorder = F) %dofuture% {
    // Add code for starting the sampling of a (fairly long-running) STAN model
    // .. e.g. different(ly parameterised) models or data depending on i
}

Expected behavior
Same as when running STAN models directly: Interrupting the R script execution should immediately interrupt the sampling process.

Operating system
Ubuntu 22.04 LTS

CmdStanR version number
0.9.0

@jfsalzmann jfsalzmann added the bug Something isn't working label May 7, 2025
@jgabry
Copy link
Member

jgabry commented May 9, 2025

Thank you for reporting this.

I haven't had a chance to test this for myself yet. I guess there are a bunch of possibilities here since this involves future, foreach, cmdstanr, CmdStan itself, and also processx, which is the package cmdstanr uses to run and control system processes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants