caikit.core.toolkit.concurrency.pickling_exception
An ExceptionPickler deals with deconstructing any Exception type into picklable parts so that it can be passed across a subprocess boundary without either failing to un-pickle or losing important context.
The python BaseException class implements its own __reduce__ method so that all subclasses support pickling, but it has some intentional drawbacks: 1. It can’t know about kwarg arguments to __init__, so it only supports subclasses that have *arg initializers. However, many custom Exception types contain keyword arguments in their __init__ methods which cause an unpickling failure. 2. It does not pickle the __cause__ or __context__ of an exception, presumably because it can’t make any guarantees about the picklability of those objects. This leads to one-line tracebacks on the unpickled exception, because there is no context to generate a useful stack trace from.
Attributes
Exceptions
Exception type used to replace exceptions that just cannot be pickled no matter |
Classes
Instances of this class can safely be pickled with any exception inside |
Module Contents
- caikit.core.toolkit.concurrency.pickling_exception.error
- exception caikit.core.toolkit.concurrency.pickling_exception.PickleFailureFallbackException[source]
Bases:
ExceptionException type used to replace exceptions that just cannot be pickled no matter how hard we try.
- class caikit.core.toolkit.concurrency.pickling_exception.ExceptionPickler(exception: BaseException)[source]
Instances of this class can safely be pickled with any exception inside
- _type_error_expression
- _arg_match_expression
- exception
- get() BaseException[source]
Returns the exception, reconstructed after pickling as best as possible
- __setstate__(state_dict)[source]
Reconstructs the exception out of the state_dict that is returned by __getstate__
- __getstate__() dict[source]
Package up the exception’s details into a dict, taking care to: - include the __cause__ and __context__, which are not serialized by default
Recursively wrap _those_ in PicklingExceptionWrappers
- Check that this exception _can_ be pickled, and try to handle common problems with
__reduce__