def get_pickleable_exception(exc):
 nearest = find_nearest_pickleable_exception(exc)
 if nearest:
  return nearest
 try:
  pickle.dumps(deepcopy(exc))
 except Exception:
  return UnpickleableExceptionWrapper.from_exception(exc)
 return exc

def get_pickleable_exception ( exc ) : nearest = find_nearest_pickleable_exception ( exc ) if nearest : return nearest try : pickle . dumps ( deepcopy ( exc ) ) except Exception : return UnpickleableExceptionWrapper . from_exception ( exc ) return exc
make sure exception is pickleable .