예제 #1
0
 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
예제 #2
0
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))
예제 #3
0
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))
예제 #4
0
 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)))
예제 #5
0
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))
예제 #6
0
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))
예제 #7
0
파일: protocol.py 프로젝트: LHYAha/rpc_demo
 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))
예제 #8
0
 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)
예제 #9
0
파일: protocol.py 프로젝트: sccn/SNAP
 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)
예제 #10
0
 def _handle_pickle(self, obj, proto):
     if not self._config["allow_pickle"]:
         raise ValueError("pickling is disabled")
     return bytes(pickle.dumps(obj, proto))