This document describes the current stable version of Celery (3.1). For development docs, go here.
celery.utils.serialization¶
celery.utils.serialization¶
Utilities for safely pickling exceptions.
-
exception
celery.utils.serialization.
UnpickleableExceptionWrapper
(exc_module, exc_cls_name, exc_args, text=None)[source]¶ Wraps unpickleable exceptions.
Parameters: - exc_module – see
exc_module
. - exc_cls_name – see
exc_cls_name
. - exc_args – see
exc_args
Example
>>> def pickle_it(raising_function): ... try: ... raising_function() ... except Exception as e: ... exc = UnpickleableExceptionWrapper( ... 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.
- exc_module – see
-
celery.utils.serialization.
find_pickleable_exception
(exc, loads=<built-in function loads>, dumps=<built-in function dumps>)[source]¶ 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 skipsException
,BaseException
andobject
). If that happens you should useUnpickleableException
instead.Parameters: exc – An exception instance. Will return the nearest pickleable parent exception class (except
Exception
and parents), or if the exception is pickleable it will returnNone
.:rtype
Exception
:
-
celery.utils.serialization.
create_exception_cls
(name, module, parent=None)[source]¶ Dynamically create an exception class.
-
celery.utils.serialization.
get_pickleable_exception
(exc)[source]¶ Make sure exception is pickleable.
-
celery.utils.serialization.
get_pickleable_etype
(cls, loads=<built-in function loads>, dumps=<built-in function dumps>)[source]¶
-
celery.utils.serialization.
get_pickled_exception
(exc)[source]¶ Get original exception from exception pickled using
get_pickleable_exception()
.