Stop workers, causing them to exit. Workers can be stopped in a few different ways (see Details), but after executing this function, assume that any worker targeted will no longer be available to work on tasks.
Usage
rrq_worker_stop(
worker_ids = NULL,
type = "message",
timeout = 0,
time_poll = 0.1,
progress = NULL,
controller = NULL
)Arguments
- worker_ids
Optional vector of worker ids. If
NULLthen all active workers will be stopped.- type
The strategy used to stop the workers. Can be
message,killorkill_local(see Details).- timeout
Optional timeout; if greater than zero then we poll for a response from the worker for this many seconds until they acknowledge the message and stop (only has an effect if
typeismessage). If a timeout of greater than zero is given, then for amessage-based stop we wait up to this many seconds for the worker to exit. That means that we might wait up to2 * timeoutseconds for this function to return.- time_poll
If
typeismessageandtimeoutis greater than zero, this is the polling interval used between redis calls. Increasing this reduces network load but decreases the ability to interrupt the process.- progress
Optional logical indicating if a progress bar should be displayed. If
NULLwe fall back on the value of the global optionrrq.progress, and if that is unset display a progress bar if in an interactive session.- controller
The controller to use. If not given (or
NULL) we'll use the controller registered withrrq_default_controller_set().
Details
The type parameter indicates the strategy used to stop workers,
and interacts with other parameters. The strategies used by the
different values are:
message, in which case aSTOPmessage will be sent to the worker, which they will receive after finishing any currently running task (ifRUNNING;IDLEworkers will stop immediately).kill, in which case a kill signal will be sent via the heartbeat (if the worker is using one). This will kill the worker even if is currently working on a task, eventually leaving that task with a status ofDIED.kill_local, in which case a kill signal is sent using operating system signals, which requires that the worker is on the same machine as the controller.
Examples
if (FALSE) { # rrq:::enable_examples(require_queue = "rrq:example")
obj <- rrq_controller("rrq:example")
w <- rrq_worker_spawn(controller = obj)
rrq_worker_list(controller = obj)
rrq_worker_stop(w$id, timeout = 10, controller = obj)
rrq_worker_list(controller = obj)
}