autoStopCluster function

Automatically Stop a Cluster when Garbage Collected

Automatically Stop a Cluster when Garbage Collected

Registers a finalizer to a cluster such that the cluster will be stopped when garbage collected

autoStopCluster(cl, debug = FALSE)

Arguments

  • cl: A cluster object created by for instance makeClusterPSOCK()

    or parallel::makeCluster().

  • debug: If TRUE, then debug messages are produced when the cluster is garbage collected.

Returns

The cluster object with attribute gcMe set.

Details

The cluster is stopped using stopCluster(cl). An alternative to explicitly call this function on an existing cluster object, is to create the cluster object using makeClusterPSOCK() with argument autoStop = TRUE.

Examples

cl <- makeClusterPSOCK(2, dryrun = TRUE) cl <- autoStopCluster(cl) print(cl) rm(list = "cl") gc()