How to solve R future error "error in future$uuid : object of type closure is not subsettable"

123 Views Asked by At

When trying to register a future with a parallel backend in R, I receive the following error message:

Error in future$uuid : object of type 'closure' is not subsettable

Previously using future has always been fine.

My code:

# Previously installed future, doFuture, parallel and doParallel packages
library(future)
library(doFuture)

registerDoFuture()
no.clusters = max(detectCores()-4,1)
cl = parallel::makeCluster(no.clusters)
plan(cluster, workers = cl)

The error occurs when running the plan command. Restarting RStudio solves the issue for one run, but running the code a second time in the same session causes the error. Obviously, I'd prefer not having to restart RStudio and import all the data etc. every time I want to use the parallel programming, so help would be appreciated

Traceback:

16: FutureCondition(message = message, call = call, uuid = uuid, 
        future = future)
15: FutureError(sprintf("Cannot resolve %s (%s), because the connection to the worker is corrupt: %s", 
        class(x)[1], label, attr(isValid, "reason", exact = TRUE)), 
        future = future)
14: stop(FutureError(sprintf("Cannot resolve %s (%s), because the connection to the worker is corrupt: %s", 
        class(x)[1], label, attr(isValid, "reason", exact = TRUE)), 
        future = future))
13: resolved.ClusterFuture(future, run = FALSE)
12: resolved(future, run = FALSE)
11: collectValues(where, futures = futures, firstOnly = TRUE)
10: FutureRegistry(reg, action = "collect-first", earlySignal = TRUE)
9: await()
8: requestNode(await = function() {
       FutureRegistry(reg, action = "collect-first", earlySignal = TRUE)
   }, workers = workers)
7: run.ClusterFuture(future)
6: run(future)
5: strategy(..., envir = envir, workers = workers)
4: evaluator(NA, label = "future-plan-test", globals = FALSE, lazy = FALSE)
3: plan_init()
2: plan_set(newStack, skip = .skip, cleanup = .cleanup, init = .init)
1: plan(cluster, workers = cl)
1

There are 1 best solutions below

0
On

future essentially creates R processes in the background to facilitate parallel computing. I believe this error might be occurring when one of the child R process is still working on things when you abort the main process. Letting the process finish or manually killing the child R process before you run again might solve this problem.