class RemoteExceptionWrapper: def __init__(self, e_type, e_value, traceback): self.e_type = dill.dumps(e_type) self.e_value = dill.dumps(e_value) self.e_traceback = Traceback(traceback) def reraise(self): reraise(dill.loads(self.e_type), dill.loads(self.e_value), self.e_traceback.as_traceback())
class ExceptionWrapper: """A picklable wrapper suitable for passing exception tracebacks through instances of ``multiprocessing.Queue``. Args: exception (Exception): The exception to wrap. """ def __init__(self, exception): # coverage: disable self.exception = exception _, _, tb = sys.exc_info() self.tb = Traceback(tb) def reraise(self): """Re-raise the exception.""" raise self.exception.with_traceback(self.tb.as_traceback())
class RemoteExceptionWrapper: def __init__(self, e_type, e_value, traceback): self.e_type = dill.dumps(e_type) self.e_value = dill.dumps(e_value) self.e_traceback = Traceback(traceback) def reraise(self): t = dill.loads(self.e_type) # the type is logged here before deserialising v and tb # because occasionally there are problems deserialising the # value (see #785, #548) and the fix is related to the # specific exception type. logger.debug("Reraising exception of type {}".format(t)) v = dill.loads(self.e_value) tb = self.e_traceback.as_traceback() reraise(t, v, tb)