-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Background
Some package register dopar adaptors internally, e.g.
pkg_fcn <- function() {
registerDoMC(4)
...
}
This, rather common, design pattern breaks whatever the user has previously set for whatever foreach purposes they have. For example, the following will not do what the user expects:
registerDoRedis()
y <- pkg_fcn() ## <= silently registers another dopar adaptor
z <- foreach(x = 1:3) %dopar% { sqrt(x) }
Sometimes, these re-registrations happens deep down in the package dependency graphs making them really hard to locate.
Suggestion
Provide a way for package developers to temporarily register a dopar adapter using:
pkg_fcn <- function() {
oldDoPar <- registerDoMC(4)
on.exit(foreach::setDoPar(oldDoPar))
...
}
Metadata
Metadata
Assignees
Labels
No labels