def __init__(self, wrappee): for name, value in inspect.getmembers(wrappee): if not hasattr(self, name): try: setattr(self, name, pickle.loads(pickle.dumps(value))) except TypeError: pass
def obtain(proxy): """obtains (copies) a remote object from a proxy object. the object is ``pickled`` on the remote side and ``unpickled`` locally, thus moved **by value**. changes made to the local object will not reflect remotely. :param proxy: an RPyC proxy object .. note:: the remote object to must be ``pickle``-able :returns: a copy of the remote object """ return pickle.loads(pickle.dumps(proxy))
def deliver(self, local_obj): """ More caching version of rpyc.classic.deliver() """ try: local_obj = object.__getattribute__(local_obj, "__remote_end__") except AttributeError: pass if isinstance(local_obj, netref.BaseNetref) and local_obj.____conn__ is self: return local_obj return self._remote_pickle_loads(bytes(pickle.dumps(local_obj)))
def deliver(conn, localobj): """delivers (recreates) a local object on the other party. the object is ``pickled`` locally and ``unpickled`` on the remote side, thus moved **by value**. changes made to the remote object will not reflect locally. :param conn: the RPyC connection :param localobj: the local object to deliver .. note:: the object must be ``picklable`` :returns: a proxy to the remote object """ return conn.modules["rpyc.lib.compat"].pickle.loads(pickle.dumps(localobj))
def _handle_pickle(self, obj, proto): # request handler if not self._config["allow_pickle"]: raise ValueError("pickling is disabled") return bytes(pickle.dumps(obj, proto))
def _handle_pickle(self, oid, proto): if not self._config["allow_pickle"]: raise ValueError("pickling is disabled") return pickle.dumps(self._local_objects[oid], proto)
def _handle_pickle(self, obj, proto): if not self._config["allow_pickle"]: raise ValueError("pickling is disabled") return bytes(pickle.dumps(obj, proto))