| crew_class_launcher_local {crew} | R Documentation |
Local process launcher class
Description
R6 class to launch and manage local process workers.
Details
Super class
crew::crew_class_launcher -> crew_class_launcher_local
Active bindings
local_log_directorylocal_log_join
Methods
Public methods
Inherited methods
crew::crew_class_launcher$active()crew::crew_class_launcher$booting()crew::crew_class_launcher$call()crew::crew_class_launcher$done()crew::crew_class_launcher$errors()crew::crew_class_launcher$forward()crew::crew_class_launcher$launch()crew::crew_class_launcher$rotate()crew::crew_class_launcher$scale()crew::crew_class_launcher$set_name()crew::crew_class_launcher$settings()crew::crew_class_launcher$start()crew::crew_class_launcher$summary()crew::crew_class_launcher$tally()crew::crew_class_launcher$terminate()crew::crew_class_launcher$terminate_workers()crew::crew_class_launcher$unlaunched()crew::crew_class_launcher$wait()
Method new()
Local launcher constructor.
Usage
crew_class_launcher_local$new( name = NULL, seconds_interval = NULL, seconds_timeout = NULL, seconds_launch = NULL, seconds_idle = NULL, seconds_wall = NULL, seconds_exit = NULL, tasks_max = NULL, tasks_timers = NULL, reset_globals = NULL, reset_packages = NULL, reset_options = NULL, garbage_collection = NULL, launch_max = NULL, tls = NULL, processes = NULL, local_log_directory = NULL, local_log_join = NULL )
Arguments
nameSee
crew_launcher().seconds_intervalSee
crew_launcher().seconds_timeoutSee
crew_launcher().seconds_launchSee
crew_launcher().seconds_idleSee
crew_launcher().seconds_wallSee
crew_launcher().seconds_exitSee
crew_launcher().tasks_maxSee
crew_launcher().tasks_timersSee
crew_launcher().reset_globalsSee
crew_launcher().reset_packagesSee
crew_launcher().reset_optionsSee
crew_launcher().garbage_collectionSee
crew_launcher().launch_maxSee
crew_launcher().tlsSee
crew_launcher().processesSee
crew_launcher().local_log_directorylocal_log_join
Returns
An R6 object with the local 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()
}
Method validate()
Validate the local launcher.
Usage
crew_class_launcher_local$validate()
Returns
NULL (invisibly).
Method launch_worker()
Launch a local process worker which will dial into a socket.
Usage
crew_class_launcher_local$launch_worker(call, name, launcher, worker, instance)
Arguments
callCharacter of length 1 with a namespaced call to
crew_worker()which will run in the worker and accept tasks.nameCharacter of length 1 with a long informative worker name which contains the
launcher,worker, andinstancearguments described below.launcherCharacter of length 1, name of the launcher.
workerPositive integer of length 1, index of the worker. This worker index remains the same even when the current instance of the worker exits and a new instance launches. It is always between 1 and the maximum number of concurrent workers.
instanceCharacter of length 1 to uniquely identify the current instance of the worker a the index in the launcher.
Details
The call argument is R code that will run to
initiate the worker. Together, the launcher, worker,
and instance arguments are useful for
constructing informative job names.
Returns
A handle object to allow the termination of the worker later on.
Method terminate_worker()
Terminate a local process worker.
Usage
crew_class_launcher_local$terminate_worker(handle)
Arguments
handleA process handle object previously returned by
launch_worker().
Returns
A list with the process ID of the worker.
See Also
Other plugin_local:
crew_controller_local(),
crew_launcher_local()
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()
}
## ------------------------------------------------
## Method `crew_class_launcher_local$new`
## ------------------------------------------------
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()
}