I am using the parallel
package to run a server function multiple times at once. The server function loops until the session is manually stopped by the user.
It looks like:
library(parallel)
cluster <- makeCluster(3)
clusterCall(cluster, f)
On Windows, parallel
works by creating an Rscript
process for each worker in a cluster. However, these processes do not get closed when terminating the R session; they must be manually removed in the task manager. With a dozen or so workers, this is quickly becoming a hassle.
Is it possible to set these processes to close when the parent R session closes?
You always must close the connections after the parallel processing. Try the following example:
library(parallel)
cluster <- makeCluster(3)
clusterCall(cluster, f)
stopCluster(cluster) # always add this line in the end of the script