def dump(self, value, f): try: pickle.dump(value, f, pickle_protocol) except pickle.PickleError: raise except Exception as e: msg = "Could not serialize broadcast: %s: %s" % (e.__class__.__name__, str(e)) print_exec(sys.stderr) raise pickle.PicklingError(msg) f.close()
def dumps(self, obj): try: return cloudpickle.dumps(obj, pickle_protocol) except pickle.PickleError: raise except Exception as e: emsg = str(e) if "'i' format requires" in emsg: msg = "Object too large to serialize: %s" % emsg else: msg = "Could not serialize object: %s: %s" % (e.__class__.__name__, emsg) print_exec(sys.stderr) raise pickle.PicklingError(msg)