setExport {doRedis} | R Documentation |
Manually add symbol names to the worker environment export list.
Description
The setExport function lets users manually declare symbol names of corresponding objects that should be exported to workers.
Usage
setExport(names = c())
Arguments
names |
A character vector of symbol names to export. |
Details
The foreach
function includes a similar .export
parameter.
We provide this supplemental export option for users without direct access
to the foreach
function, for example, when foreach
is used
inside another package.
Value
The value of names
is invisibly returned (this function is used ofr its side effect).
Examples
## Not run:
registerDoRedis("work queue")
startLocalWorkers(n=1, queue="work queue", linger=1)
f <- function() pi
(foreach(1) %dopar% tryCatch(eval(call("f")), error = as.character))
# Returns the error converted to a message:
# Error in eval(call("f")) : task 1 failed - could not find function "f"
# Manually export the symbol f:
setExport("f")
(foreach(1) %dopar% eval(call("f")))
# Now f is found.
removeQueue("work queue")
## End(Not run)
[Package doRedis version 3.0.2 Index]