# 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({'____conn__', '____id_pack__', '____refcount__', '__array_interface__', '__array_struct__', '__class__', '__cmp__', '__del__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__exit__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__instancecheck__', '__le__', '__lt__', '__metaclass__', '__methods__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__slots__', '__str__', '__weakref__'})

  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)

  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_XXX` members of `rpyc.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)

  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_XXX` members of `rpyc.protocol.consts`)

    - args – arguments to the handler

  Returns:

    an `AsyncResult` representing the operation

class rpyc.core.netref.NetrefMetaclass

  A metaclass used to customize the `__repr__` of `netref` classes. It is quite useless, but it makes debugging and interactive programming easier

class rpyc.core.netref.BaseNetref(conn, id_pack)

  The base netref class, from which all netref classes derive. Some netref classes are “pre-generated” and cached upon importing this module (those defined in the `_builtin_types`), and they are shared between all connections.

  The rest of the netref classes are created by `rpyc.core.protocl.Connection._unbox()`, and are private to the connection.

  Do not use this class directly; use `class_factory()` instead.

  Parameters:

    - conn – the `rpyc.core.protocol.Connection` instance

    - id_pack –

      id tuple for an object ~ (name_pack, remote-class-id, remote-instance-id) (cont.) name_pack := __module__.__name__ (hits or misses on builtin cache and sys.module)

      > remote-class-id := id of object class (hits or misses on netref classes cache and instance checks) remote-instance-id := id object instance (hits or misses on proxy cache)

      id_pack is usually created by rpyc.lib.get_id_pack

class rpyc.core.netref.NetrefClass(class_obj)

  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

rpyc.core.netref.class_factory(id_pack, methods)

  Creates a netref class proxying the given class

  Parameters:

    - id_pack – the id pack used for proxy communication

    - methods – a list of `(method name, docstring)` tuples, of the methods that the class defines

  Returns:

    a netref class

# Async

class rpyc.core.async_.AsyncResult(conn)

  AsyncResult represents a computation that occurs in the background and will eventually have a result. Use the `value` property to access the result (which will block if the result has not yet arrived).

  wait()

    Waits for the result to arrive. If the AsyncResult object has an expiry set, and the result did not arrive within that timeout, an `AsyncResultTimeout` exception is raised

  add_callback(func)

    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)

    Sets the expiry time (in seconds, relative to now) or `None` for 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, `AsyncResultTimeout` is raised. If the returned result is an exception, it will be raised here. Otherwise, the result is returned directly.