This document describes an older version of Celery (2.2). For the latest stable version please go here.

celery.result

class celery.result.AsyncResult(task_id, backend=None, task_name=None, app=None)

Pending task result using the default backend.

Parameters:task_id – The tasks uuid.
backend = None

Task result store backend to use.

class celery.result.BaseAsyncResult(task_id, backend, task_name=None, app=None)

Base class for pending result, supports custom task result backend.

Parameters:
exception TimeoutError

Error raised for timeouts.

BaseAsyncResult.backend = None

The task result backend to use.

BaseAsyncResult.failed()

Returns True if the task failed by exception.

BaseAsyncResult.forget()

Forget about (and possibly remove the result of) this task.

BaseAsyncResult.get(timeout=None, propagate=True, interval=0.5)

Wait until task is ready, and return its result.

Warning

Waiting for subtasks may lead to deadlocks. Please read Avoid launching synchronous subtasks.

Parameters:
  • timeout – How long to wait, in seconds, before the operation times out.
  • propagate – Re-raise exception if the task failed.
  • interval – Time to wait (in seconds) before retrying to retrieve the result. Note that this does not have any effect when using the AMQP result store backend, as it does not use polling.
Raises celery.exceptions.TimeoutError:
 

if timeout is not None and the result does not arrive within timeout seconds.

If the remote call raised an exception then that exception will be re-raised.

BaseAsyncResult.info

Get state metadata. Alias to result().

BaseAsyncResult.ready()

Returns True if the task has been executed.

If the task is still running, pending, or is waiting for retry then False is returned.

BaseAsyncResult.result

When the task has been executed, this contains the return value. If the task raised an exception, this will be the exception instance.

BaseAsyncResult.revoke(connection=None, connect_timeout=None)

Send revoke signal to all workers.

Any worker receiving the task, or having reserved the task, must ignore it.

BaseAsyncResult.state

The tasks current state.

Possible values includes:

PENDING

The task is waiting for execution.

STARTED

The task has been started.

RETRY

The task is to be retried, possibly because of failure.

FAILURE

The task raised an exception, or has been retried more times than its limit. The result attribute contains the exception raised.

SUCCESS

The task executed successfully. The result attribute contains the resulting value.
BaseAsyncResult.status

Deprecated alias of state.

BaseAsyncResult.successful()

Returns True if the task executed successfully.

BaseAsyncResult.task_id = None

The task uuid.

BaseAsyncResult.traceback

Get the traceback of a failed task.

BaseAsyncResult.wait(*args, **kwargs)

Deprecated alias to get().

class celery.result.EagerResult(task_id, ret_value, state, traceback=None)

Result that we know has already been executed.

exception TimeoutError

The operation timed out.

EagerResult.get(timeout=None, propagate=True, **kwargs)

Wait until the task has been executed and return its result.

EagerResult.ready()

Returns True if the task has been executed.

EagerResult.result

The tasks return value

EagerResult.revoke()
EagerResult.state

The tasks state.

EagerResult.status

The tasks status (alias to state).

EagerResult.successful()

Returns True if the task executed without failure.

EagerResult.traceback

The traceback if the task failed.

class celery.result.TaskSetResult(taskset_id, subtasks, app=None)

Working with TaskSet results.

An instance of this class is returned by TaskSet‘s apply_async(). It enables inspection of the subtasks state and return values as a single entity.

Parameters:
  • taskset_id – The id of the taskset.
  • subtasks – List of result instances.
completed_count()

Task completion count.

Returns:the number of tasks completed.
failed()

Did the taskset fail?

Returns:True if any of the tasks in the taskset failed. (i.e., raised an exception)
forget()

Forget about (and possible remove the result of) all the tasks in this taskset.

iter_native(timeout=None)
iterate()

Iterate over the return values of the tasks as they finish one by one.

Raises:The exception if any of the tasks raised an exception.
itersubtasks()

Taskset subtask iterator.

Returns:an iterator for iterating over the tasksets AsyncResult objects.
join(timeout=None, propagate=True, interval=0.5)

Gathers the results of all tasks in the taskset, and returns a list ordered by the order of the set.

Note

This can be an expensive operation for result store backends that must resort to polling (e.g. database).

You should consider using join_native() if your backend supports it.

Warning

Waiting for subtasks may lead to deadlocks. Please see Avoid launching synchronous subtasks.

Parameters:
  • timeout – The number of seconds to wait for results before the operation times out.
  • propagate – If any of the subtasks raises an exception, the exception will be re-raised.
  • interval – Time to wait (in seconds) before retrying to retrieve a result from the set. Note that this does not have any effect when using the AMQP result store backend, as it does not use polling.
Raises celery.exceptions.TimeoutError:
 

if timeout is not None and the operation takes longer than timeout seconds.

join_native(timeout=None, propagate=True)

Backend optimized version of join().

New in version 2.2.

Note that this does not support collecting the results for different task types using different backends.

This is currently only supported by the AMQP result backend.

ready()

Is the task ready?

Returns:True if all of the tasks in the taskset has been executed.
classmethod restore(taskset_id, backend=None)

Restore previously saved taskset result.

revoke(connection=None, connect_timeout=None)

Revoke all subtasks.

save(backend=None)

Save taskset result for later retrieval using restore().

Example:

>>> result.save()
>>> result = TaskSetResult.restore(taskset_id)
subtasks = None

A list of AsyncResult instances for all of the subtasks.

successful()

Was the taskset successful?

Returns:True if all of the tasks in the taskset finished successfully (i.e. did not raise an exception).
taskset_id = None

The UUID of the taskset.

total

Total number of subtasks in the set.

waiting()

Is the taskset waiting?

Returns:True if any of the tasks in the taskset is still waiting for execution.

Previous topic

celery.task.sets

Next topic

celery.task

This Page