2

I am iterating over a function that uses future_lapply(). I want to parallelize the outside lapply, for which I would use the following code:

plan(multisession, workers = 10)
future_lapply(X = 1:10, FUN = myfun)

Now, myfun() has its own future_lapply() inside. How do I configure the plan inside myfun() so that it does not mess up with the outside plan?

Inside myFun(), I am using

o.plan <- plan()
plan(sequential) 
on.exit(plan(o.plan), add = TRUE)

Is this the correct approach?

4

0 回答 0