Celery.Result (celery v0.1.0)

Copy Markdown View Source

Task result handle (AsyncResult in Python Celery, ported from celery.result.AsyncResult).

Provides querying of task state, result value, traceback, and blocking get/2 backed by Celery.Backend.Redis, as well as local eager execution results.

Summary

Functions

Returns the full task metadata map from Redis.

Creates an eager %Celery.Result{} (EagerResult in Python Celery).

Returns true if the task failed (state == "FAILURE").

Forgets (deletes) the result from the Redis result backend.

Waits until the task is ready and returns its result.

Alias for result/1 (matches AsyncResult.info in Python Celery).

Creates a new %Celery.Result{} (AsyncResult) for task_id.

Returns true if the task has been executed (SUCCESS, FAILURE, or REVOKED).

Returns the task's stored result (or exception struct if failed, or nil if pending).

Revokes the task by marking it revoked in the backend and optionally broadcasting a revoke control command over Kombu.Pidbox.

Returns the task's current state ("PENDING", "STARTED", "SUCCESS", "FAILURE", "REVOKED", "RETRY").

Alias for state/1 (matches AsyncResult.status in Python Celery).

Returns true if the task succeeded (state == "SUCCESS").

Returns the traceback of a failed task (or nil).

Types

t()

@type t() :: %Celery.Result{
  app: Celery.t() | Celery.Config.t() | nil,
  eager_result: term(),
  eager_state: String.t() | nil,
  eager_traceback: String.t() | nil,
  id: String.t(),
  is_eager: boolean(),
  parent: t() | nil
}

Functions

backend_meta(res)

@spec backend_meta(t()) :: map()

Returns the full task metadata map from Redis.

eager(task_id, result, state \\ States.success(), opts \\ [])

@spec eager(String.t(), term(), String.t(), keyword()) :: t()

Creates an eager %Celery.Result{} (EagerResult in Python Celery).

failed?(res)

@spec failed?(t()) :: boolean()

Returns true if the task failed (state == "FAILURE").

forget(result)

@spec forget(t()) :: :ok

Forgets (deletes) the result from the Redis result backend.

get(res, opts \\ [])

@spec get(t(), keyword()) :: term()

Waits until the task is ready and returns its result.

Options:

  • :timeout - timeout in milliseconds, float seconds, or :infinity (default :infinity)
  • :interval - poll interval in milliseconds (default 50)
  • :propagate - re-raise exception if the task failed or was revoked (default true)

info(res)

@spec info(t()) :: term()

Alias for result/1 (matches AsyncResult.info in Python Celery).

new(task_id, opts \\ [])

@spec new(String.t(), keyword()) :: t()

Creates a new %Celery.Result{} (AsyncResult) for task_id.

ready?(res)

@spec ready?(t()) :: boolean()

Returns true if the task has been executed (SUCCESS, FAILURE, or REVOKED).

result(result)

@spec result(t()) :: term()

Returns the task's stored result (or exception struct if failed, or nil if pending).

revoke(result, opts \\ [])

@spec revoke(t(), keyword()) :: :ok

Revokes the task by marking it revoked in the backend and optionally broadcasting a revoke control command over Kombu.Pidbox.

state(result)

@spec state(t()) :: String.t()

Returns the task's current state ("PENDING", "STARTED", "SUCCESS", "FAILURE", "REVOKED", "RETRY").

status(res)

@spec status(t()) :: String.t()

Alias for state/1 (matches AsyncResult.status in Python Celery).

successful?(res)

@spec successful?(t()) :: boolean()

Returns true if the task succeeded (state == "SUCCESS").

traceback(result)

@spec traceback(t()) :: String.t() | nil

Returns the traceback of a failed task (or nil).