Create an R6
object to launch and maintain
local process workers.
crew_launcher_local(
name = NULL,
seconds_interval = 0.25,
seconds_launch = 30,
seconds_idle = Inf,
seconds_wall = Inf,
seconds_exit = 1,
tasks_max = Inf,
tasks_timers = 0L,
reset_globals = TRUE,
reset_packages = FALSE,
reset_options = FALSE,
garbage_collection = FALSE,
launch_max = 5L,
tls = crew::crew_tls()
)
Name of the launcher.
Seconds to wait between asynchronous operations.
Seconds of startup time to allow.
A worker is unconditionally assumed to be alive
from the moment of its launch until seconds_launch
seconds later.
After seconds_launch
seconds, the worker is only
considered alive if it is actively connected to its assign websocket.
Maximum number of seconds that a worker can idle
since the completion of the last task. If exceeded, the worker exits.
But the timer does not launch until tasks_timers
tasks
have completed.
See the idletime
argument of mirai::daemon()
. crew
does not
excel with perfectly transient workers because it does not micromanage
the assignment of tasks to workers, so please allow enough idle
time for a new worker to be delegated a new task.
Soft wall time in seconds.
The timer does not launch until tasks_timers
tasks
have completed.
See the walltime
argument of mirai::daemon()
.
Number of seconds to wait for NNG websockets
to finish sending large data (when a worker exits after reaching a
timeout or having completed a certain number of tasks).
See the exitlinger
argument of mirai::daemon()
.
Maximum number of tasks that a worker will do before
exiting. See the maxtasks
argument of mirai::daemon()
.
crew
does not
excel with perfectly transient workers because it does not micromanage
the assignment of tasks to workers, it is recommended to set
tasks_max
to a value greater than 1.
Number of tasks to do before activating
the timers for seconds_idle
and seconds_wall
.
See the timerstart
argument of mirai::daemon()
.
TRUE
to reset global environment
variables between tasks, FALSE
to leave them alone.
TRUE
to unload any packages loaded during
a task (runs between each task), FALSE
to leave packages alone.
TRUE
to reset global options to their original
state between each task, FALSE
otherwise. It is recommended to
only set reset_options = TRUE
if reset_packages
is also TRUE
because packages sometimes rely on options they set at loading time.
TRUE
to run garbage collection between
tasks, FALSE
to skip.
Positive integer of length 1, maximum allowed
consecutive launch attempts which do not complete any tasks.
Enforced on a worker-by-worker basis.
The futile launch count resets to back 0
for each worker that completes a task.
It is recommended to set launch_max
above 0
because sometimes workers are unproductive under perfectly ordinary
circumstances. But launch_max
should still be small enough
to detect errors in the underlying platform.
A TLS configuration object from crew_tls()
.
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
client <- crew_client()
client$start()
launcher <- crew_launcher_local(name = client$name)
launcher$start(workers = client$workers)
launcher$launch(index = 1L)
m <- mirai::mirai("result", .compute = client$name)
Sys.sleep(0.25)
m$data
client$terminate()
}
Run the code above in your browser using DataLab