find_pickleable_exception
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 :exc:`Exception` (i.e., it skips :exc:`Exception`,
:class:`BaseException` and :class:`object`). If that happens
you should use :exc:`UnpickleableException` instead.
def find_pickleable_exception(
exc: BaseException,
loads: callable = pickle.loads,
dumps: callable = pickle.dumps
) - > Exception
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 :exc:Exception (i.e., it skips :exc:Exception, :class:BaseException and :class:object). If that happens you should use :exc:UnpickleableException instead.
Parameters
| Name | Type | Description |
|---|---|---|
| exc | BaseException | The exception instance to inspect for pickleable parent classes. |
| loads | callable = pickle.loads | The decoding function used to verify if an exception can be reconstructed. |
| dumps | callable = pickle.dumps | The encoding function used to verify if an exception can be serialized. |
Returns
| Type | Description |
|---|---|
Exception | Nearest pickleable parent exception class (except :exc:Exception and parents), or if the exception is pickleable it will return :const:None. |