This function is useful for inheriting argument documentation
in functions that create custom third-party launchers. See
@inheritParams crew::crew_launcher
in the source code file of
crew_launcher_local()
.
Usage
crew_launcher(
name = NULL,
seconds_interval = 0.5,
seconds_timeout = 60,
seconds_launch = 30,
seconds_idle = 300,
seconds_wall = Inf,
seconds_exit = NULL,
tasks_max = Inf,
tasks_timers = 0L,
reset_globals = TRUE,
reset_packages = FALSE,
reset_options = FALSE,
garbage_collection = FALSE,
crashes_error = 5L,
launch_max = NULL,
tls = crew::crew_tls(),
processes = NULL,
r_arguments = c("--no-save", "--no-restore"),
options_metrics = crew::crew_options_metrics()
)
Arguments
- name
Name of the launcher.
- seconds_interval
Number of seconds between polling intervals waiting for certain internal synchronous operations to complete, such as checking
mirai::status()
.- seconds_timeout
Number of seconds until timing out while waiting for certain synchronous operations to complete, such as checking
mirai::status()
.- seconds_launch
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. Afterseconds_launch
seconds, the worker is only considered alive if it is actively connected to its assign websocket.- seconds_idle
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 theidletime
argument ofmirai::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.- seconds_wall
Soft wall time in seconds. The timer does not launch until
tasks_timers
tasks have completed. See thewalltime
argument ofmirai::daemon()
.- seconds_exit
Deprecated on 2023-09-21 in version 0.5.0.9002. No longer necessary.
- tasks_max
Maximum number of tasks that a worker will do before exiting. See the
maxtasks
argument ofmirai::daemon()
.crew
does not excel with perfectly transient workers because it does not micromanage the assignment of tasks to workers, it is recommended to settasks_max
to a value greater than 1.- tasks_timers
Number of tasks to do before activating the timers for
seconds_idle
andseconds_wall
. See thetimerstart
argument ofmirai::daemon()
.- reset_globals
TRUE
to reset global environment variables between tasks,FALSE
to leave them alone.- reset_packages
TRUE
to unload any packages loaded during a task (runs between each task),FALSE
to leave packages alone.- reset_options
TRUE
to reset global options to their original state between each task,FALSE
otherwise. It is recommended to only setreset_options = TRUE
ifreset_packages
is alsoTRUE
because packages sometimes rely on options they set at loading time.- garbage_collection
TRUE
to run garbage collection between tasks,FALSE
to skip.- crashes_error
Positive integer scalar. If a worker exits
crashes_error
times in a row without completing all its assigned tasks, then the launcher throws an informative error. The reason forcrashes_error
is to avoid an infinite loop where a task crashes a worker (through a segfault, maxing out memory, etc) but the worker always relaunches. To monitor the resources ofcrew
workers, please see https://wlandau.github.io/crew/articles/logging.html.- launch_max
Deprecated on 2024-11-04 (version 0.10.1.9000). Use
crashes_error
instead.- tls
A TLS configuration object from
crew_tls()
.- processes
NULL
or positive integer of length 1, number of local processes to launch to allow worker launches to happen asynchronously. IfNULL
, then no local processes are launched. If 1 or greater, then the launcher starts the processes onstart()
and ends them onterminate()
. Plugins that may use these processes should run asynchronous calls usinglauncher$async$eval()
and expect amirai
task object as the return value.- r_arguments
Optional character vector of command line arguments to pass to
Rscript
(non-Windows) orRscript.exe
(Windows) when starting a worker. Example:r_arguments = c("--vanilla", "--max-connections=32")
.- options_metrics
Either
NULL
to opt out of resource metric logging for workers, or an object fromcrew_options_metrics()
to enable and configure resource metric logging for workers. For resource logging to run, theautometric
R package version 0.1.0 or higher must be installed.
See also
Other launcher:
crew_class_launcher
Examples
if (identical(Sys.getenv("CREW_EXAMPLES"), "true")) {
client <- crew_client()
client$start()
launcher <- crew_launcher_local(name = client$name)
launcher$start(sockets = client$summary()$socket)
launcher$launch(index = 1L)
task <- mirai::mirai("result", .compute = client$name)
mirai::call_mirai_(task)
task$data
client$terminate()
}