Backend: Base - celery.backends.base

celery.backends.base

class celery.backends.base.BaseBackend

The base backend class. All backends should inherit from this.

exception TimeoutError
The operation timed out.
exception BaseBackend.UnpickleableExceptionWrapper(exc_module, exc_cls_name, exc_args)

Wraps unpickleable exceptions.

Parameters:
exc_module
The module of the original exception.
exc_cls_name
The name of the original exception class.
exc_args
The arguments for the original exception.

Example

>>> try:
...     something_raising_unpickleable_exc()
>>> except Exception, e:
...     exc = UnpickleableException(e.__class__.__module__,
...                                 e.__class__.__name__,
...                                 e.args)
...     pickle.dumps(exc) # Works fine.
BaseBackend.cleanup()
Backend cleanup. Is run by celery.task.DeleteExpiredTaskMetaTask.
BaseBackend.create_exception_cls(name, module, parent=None)
Dynamically create an exception class.
BaseBackend.exception_to_python(exc)
Convert serialized exception to Python exception.
BaseBackend.get_result(task_id)
Get the result of a task.
BaseBackend.get_status(task_id)
Get the status of a task.
BaseBackend.is_done(task_id)
Returns True if the task was successfully executed.
BaseBackend.mark_as_done(task_id, result)
Mark task as successfully executed.
BaseBackend.mark_as_failure(task_id, exc)
Mark task as executed with failure. Stores the execption.
BaseBackend.mark_as_retry(task_id, exc)
Mark task as being retries. Stores the current exception (if any).
BaseBackend.prepare_exception(exc)
Prepare exception for serialization.
BaseBackend.prepare_result(result)
Prepare result for storage.
BaseBackend.process_cleanup()

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

See celery.worker.jail().

BaseBackend.store_result(task_id, result, status)
Store the result and status of a task.
BaseBackend.wait_for(task_id, timeout=None)

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.timer.TimeoutError exception if the operation takes longer than timeout seconds.

exception celery.backends.base.TimeoutError
The operation timed out.
exception celery.backends.base.UnpickleableExceptionWrapper(exc_module, exc_cls_name, exc_args)

Wraps unpickleable exceptions.

Parameters:
exc_module
The module of the original exception.
exc_cls_name
The name of the original exception class.
exc_args
The arguments for the original exception.

Example

>>> try:
...     something_raising_unpickleable_exc()
>>> except Exception, e:
...     exc = UnpickleableException(e.__class__.__module__,
...                                 e.__class__.__name__,
...                                 e.args)
...     pickle.dumps(exc) # Works fine.
celery.backends.base.find_nearest_pickleable_exception(exc)

With an exception instance, iterate over its super classes (by mro) and find the first super exception that is pickleable. It does not go below Exception (i.e. it skips Exception, BaseException and object). If that happens you should use UnpickleableException instead.

Parameter:exc – An exception instance.
Returns:the nearest exception if it’s not Exception or below, if it is it returns None.
Return type:Exception

Previous topic

Backends - celery.backends

Next topic

Backend: Database - celery.backends.database

This Page