def from_bytes(b): ray_exception = RayException() ray_exception.ParseFromString(b) if ray_exception.language == PYTHON: return pickle.loads(ray_exception.serialized_exception) else: return CrossLanguageError(ray_exception)
def from_bytes(b): ray_exception = RayException() ray_exception.ParseFromString(b) if ray_exception.language == PYTHON: try: return pickle.loads(ray_exception.serialized_exception) except Exception as e: msg = "Failed to unpickle serialized exception" raise RuntimeError(msg) from e else: return CrossLanguageError(ray_exception)
def to_bytes(self): # Extract exc_info from exception object. exc_info = (type(self), self, self.__traceback__) formatted_exception_string = "\n".join(format_exception(*exc_info)) return RayException( language=PYTHON, serialized_exception=pickle.dumps(self), formatted_exception_string=formatted_exception_string ).SerializeToString()
def from_bytes(b): ray_exception = RayException() ray_exception.ParseFromString(b) return RayError.from_ray_exception(ray_exception)