Get the result for a single task (see rrq_task_results for a method for efficiently getting multiple results at once). Returns the value of running the task if it is complete, and an error otherwise.
Arguments
- task_id
The single id for which the result is wanted.
- error
Logical, indicating if we should throw an error if a task was not successful. By default (
error = FALSE
), in the case of the task result returning an error we return an object of classrrq_task_error
, which contains information about the error. Passingerror = TRUE
callsstop()
on this error if it is returned.- follow
Optional logical, indicating if we should follow any redirects set up by doing rrq_task_retry. If not given, falls back on the value passed into the controller, the global option
rrq.follow
, and finallyTRUE
. Set toFALSE
if you want to return information about the original task, even if it has been subsequently retried.- controller
The controller to use. If not given (or
NULL
) we'll use the controller registered withrrq_default_controller_set()
.
Value
The result of your task. This may be an error (an object
with class rrq_task_error
) if your task has failed.
Examples
if (FALSE) { # rrq:::enable_examples(require_queue = "rrq:example")
obj <- rrq_controller("rrq:example")
# Create a task, wait for it to finish and fetch its result
t <- rrq_task_create_expr(runif(1), controller = obj)
rrq_task_wait(t, controller = obj)
rrq_task_result(t, controller = obj)
# Tasks that fail do not fail on result, but instead return an
# object with the class "rrq_task_error"
t <- rrq_task_create_expr(readRDS("somefile.rds"), controller = obj)
rrq_task_wait(t, controller = obj)
rrq_task_result(t, controller = obj)
}