This document describes the current stable version of Celery (3.1). For development docs, go here.

celery.backends.base

celery.backends.base

Result backend base classes.

class celery.backends.base.BaseBackend(app, serializer=None, max_cached_results=None, accept=None, url=None, **kwargs)[source]
EXCEPTION_STATES = frozenset(['FAILURE', 'RETRY', 'REVOKED'])
READY_STATES = frozenset(['FAILURE', 'REVOKED', 'SUCCESS'])
exception TimeoutError

The operation timed out.

UNREADY_STATES = frozenset(['STARTED', 'RECEIVED', 'RETRY', 'PENDING'])
apply_chord(header, partial_args, group_id, body, **options)[source]
as_uri(include_password=False)[source]

Return the backend as an URI, sanitizing the password or not

chord_error_from_stack(callback, exc=None)[source]
cleanup()[source]

Backend cleanup. Is run by celery.task.DeleteExpiredTaskMetaTask.

current_task_children(request=None)[source]
decode(payload)[source]
decode_result(payload)[source]
delete_group(group_id)[source]
encode(data)[source]
encode_result(result, status)[source]
exception_to_python(exc)[source]

Convert serialized exception to Python exception.

fail_from_current_stack(task_id, exc=None)[source]
fallback_chord_unlock(group_id, body, result=None, countdown=1, **kwargs)[source]
forget(task_id)[source]
get_children(task_id)[source]

Get the list of subtasks sent by a task.

get_group_meta(group_id, cache=True)[source]
get_result(task_id)[source]

Get the result of a task.

get_status(task_id)[source]

Get the status of a task.

get_task_meta(task_id, cache=True)[source]
get_traceback(task_id)[source]

Get the traceback for a failed task.

is_cached(task_id)[source]
mark_as_done(task_id, result, request=None)[source]

Mark task as successfully executed.

mark_as_failure(task_id, exc, traceback=None, request=None)[source]

Mark task as executed with failure. Stores the exception.

mark_as_retry(task_id, exc, traceback=None, request=None)[source]

Mark task as being retries. Stores the current exception (if any).

mark_as_revoked(task_id, reason='', request=None)[source]
mark_as_started(task_id, **meta)[source]

Mark a task as started

meta_from_decoded(meta)[source]
on_chord_part_return(task, state, result, propagate=False)[source]
on_task_call(producer, task_id)[source]
persistent = True

Set to true if the backend is peristent by default.

prepare_exception(exc, serializer=None)[source]

Prepare exception for serialization.

prepare_expires(value, type=None)[source]
prepare_persistent(enabled=None)[source]
prepare_value(result)[source]

Prepare value for storage.

process_cleanup()[source]

Cleanup actions to do at the end of a task worker process.

reload_group_result(group_id)[source]

Reload group result, even if it has been previously fetched.

reload_task_result(task_id)[source]

Reload task result, even if it has been previously fetched.

restore_group(group_id, cache=True)[source]

Get the result for a group.

retry_policy = {'interval_start': 0, 'interval_max': 1, 'max_retries': 20, 'interval_step': 1}
save_group(group_id, result)[source]

Store the result of an executed group.

store_result(task_id, result, status, traceback=None, request=None, **kwargs)[source]

Update task state and result.

subpolling_interval = None

Time to sleep between polling each individual item in ResultSet.iterate. as opposed to the interval argument which is for each pass.

supports_autoexpire = False

If true the backend must automatically expire results. The daily backend_cleanup periodic task will not be triggered in this case.

supports_native_join = False

If true the backend must implement get_many().

wait_for(task_id, timeout=None, interval=0.5, no_ack=True, on_interval=None)[source]

Wait for task and return its result.

If the task raises an exception, this exception will be re-raised by wait_for().

If timeout is not None, this raises the celery.exceptions.TimeoutError exception if the operation takes longer than timeout seconds.

class celery.backends.base.KeyValueStoreBackend(*args, **kwargs)[source]
chord_keyprefix = 'chord-unlock-'
delete(key)[source]
expire(key, value)[source]
get(key)[source]
get_key_for_chord(group_id, key='')[source]

Get the cache key for the chord waiting on group with given id.

get_key_for_group(group_id, key='')[source]

Get the cache key for a group by id.

get_key_for_task(task_id, key='')[source]

Get the cache key for a task by id.

get_many(task_ids, timeout=None, interval=0.5, no_ack=True, READY_STATES=frozenset(['FAILURE', 'REVOKED', 'SUCCESS']))[source]
group_keyprefix = 'celery-taskset-meta-'
implements_incr = False
incr(key)[source]
key_t(s)
mget(keys)[source]
on_chord_part_return(task, state, result, propagate=None)[source]
set(key, value)[source]
task_keyprefix = 'celery-task-meta-'
class celery.backends.base.DisabledBackend(app, serializer=None, max_cached_results=None, accept=None, url=None, **kwargs)[source]
as_uri(*args, **kwargs)[source]
get_many(*args, **kwargs)
get_result(*args, **kwargs)
get_state(*args, **kwargs)
get_status(*args, **kwargs)
get_traceback(*args, **kwargs)
store_result(*args, **kwargs)[source]
wait_for(*args, **kwargs)