Netref
NetRef: a transparent network reference. This module contains quite a lot of magic, so beware.
- rpyc.core.netref.DELETED_ATTRS = frozenset({'__array_interface__', '__array_struct__'})
the set of attributes that are local to the netref object
- rpyc.core.netref.LOCAL_ATTRS = frozenset({'____bind_instance__', '____conn__', '____hash__', '____id_pack__', '____member__', '____refcount__', '__array_interface__', '__array_struct__', '__base__', '__bases__', '__bool__', '__class__', '__cmp__', '__del__', '__delattr__', '__dict__', '__dir__', '__eq__', '__exit__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__instancecheck__', '__le__', '__lt__', '__metaclass__', '__methods__', '__module__', '__mro__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__slots__', '__str__', '__subclasscheck__', '__subclasses__', '__weakref__', 'mro'})
a list of types considered built-in (shared between connections) this is needed because iterating the members of the builtins module is not enough, some types (e.g NoneType) are not members of the builtins module. TODO: this list is not complete.
- rpyc.core.netref.syncreq(proxy, handler, *args)[source]
Performs a synchronous request on the given proxy object. Not intended to be invoked directly.
- Parameters:
proxy – the proxy on which to issue the request
handler – the request handler (one of the
HANDLE_XXXmembers ofrpyc.protocol.consts)args – arguments to the handler
- Raises:
any exception raised by the operation will be raised
- Returns:
the result of the operation
- rpyc.core.netref.asyncreq(proxy, handler, *args)[source]
Performs an asynchronous request on the given proxy object. Not intended to be invoked directly.
- Parameters:
proxy – the proxy on which to issue the request
handler – the request handler (one of the
HANDLE_XXXmembers ofrpyc.protocol.consts)args – arguments to the handler
- Returns:
an
AsyncResultrepresenting the operation
- class rpyc.core.netref.NetrefMetaclass(name, bases, dct, id_pack=None)[source]
A metaclass used to customize the
__repr__ofnetrefclasses. It is quite useless, but it makes debugging and interactive programming easier
- class rpyc.core.netref.NetrefClass(class_obj)[source]
a descriptor of the class being proxied
- Future considerations:
there may be a cleaner alternative but lib.compat.with_metaclass prevented using __new__
consider using __slot__ for this class
revisit the design choice to use properties here
- property instance
accessor to class object for the instance being proxied
- property owner
accessor to the class object for the instance owner being proxied
Async
- class rpyc.core.async_.AsyncResult(conn)[source]
AsyncResult represents a computation that occurs in the background and will eventually have a result. Use the
valueproperty to access the result (which will block if the result has not yet arrived).- wait()[source]
Waits for the result to arrive. If the AsyncResult object has an expiry set, and the result did not arrive within that timeout, an
TimeoutErrorexception is raised
- add_callback(func)[source]
Adds a callback to be invoked when the result arrives. The callback function takes a single argument, which is the current AsyncResult (
self). If the result has already arrived, the function is invoked immediately.- Parameters:
func – the callback function to add
- set_expiry(timeout)[source]
Sets the expiry time (in seconds, relative to now) or
Nonefor unlimited time- Parameters:
timeout – the expiry time in seconds or
None
- property ready
Indicates whether the result has arrived
- property error
Indicates whether the returned result is an exception
- property expired
Indicates whether the AsyncResult has expired
- property value
Returns the result of the operation. If the result has not yet arrived, accessing this property will wait for it. If the result does not arrive before the expiry time elapses,
TimeoutErroris raised. If the returned result is an exception, it will be raised here. Otherwise, the result is returned directly.
