I'm trying to understand the python2 library remotely which helps to run code remotely through xmlrpc.
On the client, the author dump the object with marshal and load the result sent back from the server with pickle:
def run(self, func, *args, **kwds):
code_str = base64.b64encode(marshal.dumps(func.func_code))
output = self.proxy.run(self.api_key, self.a_sync, code_str, *args, **kwds)
return pickle.loads(base64.b64decode(output))
And on the server side, he's doing the other way around:
def run(self, api_key, a_sync, func_str, *args, **kwds):
#... truncated code
code = marshal.loads(base64.b64decode(func_str))
func = types.FunctionType(code, globals(), "remote_func")
#... truncated code
output = func(*args, **kwds)
output = base64.b64encode(pickle.dumps(output))
return output
What's the purpose of dumping with marshal and loading the result with pickle? (and vice-versa)