Ejemplo n.º 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
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 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)))
Ejemplo n.º 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))
Ejemplo n.º 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))
Ejemplo n.º 7
0
 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))
Ejemplo n.º 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)
Ejemplo n.º 9
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)
Ejemplo n.º 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))