Register a function to create an environment when creating a worker. When a worker starts, they will run this function.
Arguments
- create
A function that will create an environment. It will be called with one parameter (an environment), in a fresh R session. The function
rrq_envir()
can be used to create a suitable function for the most common case (loading packages and sourcing scripts). Set toNULL
to remove environment creation function (i.e., to start workers with an essentially empty environment).- notify
Boolean, indicating if we should send a
REFRESH
message to all workers to update their environment.- controller
The controller to use. If not given (or
NULL
) we'll use the controller registered withrrq_default_controller_set()
.
Examples
obj <- rrq_controller("rrq:example")
rrq_worker_envir_set(rrq_envir(packages = "ids"), controller = obj)
t <- rrq_task_create_expr(search(), controller = obj)
rrq_task_wait(t, controller = obj)
#> [1] TRUE
rrq_task_result(t, controller = obj)
#> [1] ".GlobalEnv" "package:ids" "package:stats"
#> [4] "package:graphics" "package:grDevices" "package:utils"
#> [7] "package:datasets" "package:methods" "Autoloads"
#> [10] "package:base"
rrq_worker_log_tail(n = 5, controller = obj)
#> worker_id child time command
#> 1 exhaustible_umbrette NA 1726673817 ENVIR
#> 2 exhaustible_umbrette NA 1726673817 ENVIR
#> 3 exhaustible_umbrette NA 1726673817 RESPONSE
#> 4 exhaustible_umbrette NA 1726673817 TASK_START
#> 5 exhaustible_umbrette NA 1726673817 TASK_COMPLETE
#> message
#> 1 new
#> 2 create
#> 3 REFRESH
#> 4 50ec25e92c8e338c96e78f4138fe7e75
#> 5 50ec25e92c8e338c96e78f4138fe7e75
rrq_worker_envir_set(NULL, controller = obj)