HenrikBengtsson / future.BatchJobs

:rocket: R package: future.BatchJobs: A Future API for Parallel and Distributed Processing using BatchJobs [Intentionally archived on CRAN on 2021-01-08]
https://cran.r-project.org/package=future.BatchJobs
8 stars 0 forks source link

%plan% batchjobs(backend=...) does not undo the backend - should it? #40

Closed HenrikBengtsson closed 9 years ago

HenrikBengtsson commented 9 years ago

Observation

> library(future)
> plan(eager)

> backend("local")
[1] "local"

> x %<=% { 1 } %plan% batchjobs(backend="interactive")
> x
[1] 1

> backend()
[1] "interactive"

Should it?

Troubleshooting

This is because batchjobs() does not undo the backend set, e.g.

> backend()
[1] "local"
> f <- batchjobs({ 1 }, backend="interactive")
> backend()
[1] "interactive"
> value(f)
[1] 1
> backend()
[1] "interactive"

This is in turn because BatchJobsAsyncTask({ 1 }, backend="interactive") does not undo it. Continuing, the problem occurs because of tempRegistry():

> backend("local")
[1] "local"
> reg <- async:::tempRegistry(backend="interactive")
Creating dir: /cbc/henrik/repositories/GitHub/async/.async/async28374250-files
Loading required package: BatchJobs
Loading required package: BBmisc
Saving registry: /cbc/henrik/repositories/GitHub/async/.async/async28374250-files/registry.RData
> backend()
[1] "interactive"