celery.utils.serialization

Utilities for safely pickling exceptions.

exception celery.utils.serialization.UnpickleableExceptionWrapper(exc_module, exc_cls_name, exc_args, text=None)[исходный код]

Wraps unpickleable exceptions.

Параметры:

Пример

>>> 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.

classmethod from_exception(exc)[исходный код]
restore()[исходный код]
celery.utils.serialization.create_exception_cls(name, module, parent=None)[исходный код]

Dynamically create an exception class.

celery.utils.serialization.find_pickleable_exception(exc, loads=<built-in function loads>, dumps=<built-in function dumps>)[исходный код]

Find first pickleable exception base class.

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

Параметры:
  • exc (BaseException) – An exception instance.

  • loads – decoder to use.

  • dumps – encoder to use

Результат:

Nearest pickleable parent exception class

(except Exception and parents), or if the exception is pickleable it will return None.

Тип результата:

Exception

celery.utils.serialization.get_pickleable_etype(cls, loads=<built-in function loads>, dumps=<built-in function dumps>)[исходный код]

Get pickleable exception type.

celery.utils.serialization.get_pickleable_exception(exc)[исходный код]

Make sure exception is pickleable.

celery.utils.serialization.get_pickled_exception(exc)[исходный код]

Reverse of get_pickleable_exception().

celery.utils.serialization.strtobool(term, table=None)[исходный код]

Convert common terms for true/false to bool.

Examples (true/false/yes/no/on/off/1/0).

celery.utils.serialization.subclass_exception(name, parent, module)[исходный код]

Create new exception class.

Вернуться на верх