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

celery.utils.serialization

celery.utils.serialization

Utilities for safely pickling exceptions.

copyright:
  1. 2009 - 2012 by Ask Solem.
license:

BSD, see LICENSE for more details.

exception celery.utils.serialization.UnpickleableExceptionWrapper(exc_module, exc_cls_name, exc_args, text=None)

Wraps unpickleable exceptions.

Parameters:

Example

>>> try:
...     something_raising_unpickleable_exc()
>>> except Exception, e:
...     exc = UnpickleableException(e.__class__.__module__,
...                                 e.__class__.__name__,
...                                 e.args)
...     pickle.dumps(exc) # Works fine.
exc_args = None

The arguments for the original exception.

exc_cls_name = None

The name of the original exception class.

exc_module = None

The module of the original exception.

classmethod from_exception(exc)
restore()
celery.utils.serialization.create_exception_cls(name, module, parent=None)

Dynamically create an exception class.

celery.utils.serialization.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.

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

:rtype Exception:

celery.utils.serialization.get_pickleable_exception(exc)

Make sure exception is pickleable.

celery.utils.serialization.get_pickled_exception(exc)

Get original exception from exception pickled using get_pickleable_exception().

celery.utils.serialization.subclass_exception(name, parent, module)
celery.utils.serialization.unwanted_base_classes = (<type 'exceptions.StandardError'>, <type 'exceptions.Exception'>, <type 'exceptions.BaseException'>, <type 'object'>)

List of base classes we probably don’t want to reduce to.

Previous topic

celery.utils.patch

Next topic

celery.utils.threads

This Page