Netref

NetRef: a transparent network reference. This module contains quite a lot of magic, so beware.

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_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)[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_XXX members of rpyc.protocol.consts)
  • args – arguments to the handler
Returns:

an AsyncResult representing the operation

class rpyc.core.netref.NetrefMetaclass[source]

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, oid)[source]

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:
rpyc.core.netref.inspect_methods(obj)[source]

introspects the given (local) object, returning a list of all of its methods (going up the MRO).

Parameters:obj – any local (not proxy) python object
Returns:a list of (method name, docstring) tuples of all the methods of the given object
rpyc.core.netref.class_factory(clsname, modname, methods)[source]

Creates a netref class proxying the given class

Parameters:
  • clsname – the class’s name
  • modname – the class’s module name
  • methods – a list of (method name, docstring) tuples, of the methods that the class defines
Returns:

a netref class

rpyc.core.netref.builtin_classes_cache = {('rangeiterator', '__builtin__'): <netref class '__builtin__.rangeiterator'>, ('tuple', '__builtin__'): <netref class '__builtin__.tuple'>, ('listiterator', '__builtin__'): <netref class '__builtin__.listiterator'>, ('str', '__builtin__'): <netref class '__builtin__.str'>, ('frozenset', '__builtin__'): <netref class '__builtin__.frozenset'>, ('BaseException', 'exceptions'): <netref class 'exceptions.BaseException'>, ('float', '__builtin__'): <netref class '__builtin__.float'>, ('file', '__builtin__'): <netref class '__builtin__.file'>, ('set', '__builtin__'): <netref class '__builtin__.set'>, ('int', '__builtin__'): <netref class '__builtin__.int'>, ('classobj', '__builtin__'): <netref class '__builtin__.classobj'>, ('dictproxy', '__builtin__'): <netref class '__builtin__.dictproxy'>, ('list', '__builtin__'): <netref class '__builtin__.list'>, ('NoneType', '__builtin__'): <netref class '__builtin__.NoneType'>, ('unicode', '__builtin__'): <netref class '__builtin__.unicode'>, ('tupleiterator', '__builtin__'): <netref class '__builtin__.tupleiterator'>, ('code', '__builtin__'): <netref class '__builtin__.code'>, ('module', '__builtin__'): <netref class '__builtin__.module'>, ('Exception', 'exceptions'): <netref class 'exceptions.Exception'>, ('slice', '__builtin__'): <netref class '__builtin__.slice'>, ('generator', '__builtin__'): <netref class '__builtin__.generator'>, ('xrange', '__builtin__'): <netref class '__builtin__.xrange'>, ('function', '__builtin__'): <netref class '__builtin__.function'>, ('complex', '__builtin__'): <netref class '__builtin__.complex'>, ('object', '__builtin__'): <netref class '__builtin__.object'>, ('long', '__builtin__'): <netref class '__builtin__.long'>, ('wrapper_descriptor', '__builtin__'): <netref class '__builtin__.wrapper_descriptor'>, ('instancemethod', '__builtin__'): <netref class '__builtin__.instancemethod'>, ('instance', '__builtin__'): <netref class '__builtin__.instance'>, ('method-wrapper', '__builtin__'): <netref class '__builtin__.method-wrapper'>, ('dict', '__builtin__'): <netref class '__builtin__.dict'>, ('setiterator', '__builtin__'): <netref class '__builtin__.setiterator'>, ('frame', '__builtin__'): <netref class '__builtin__.frame'>, ('type', '__builtin__'): <netref class '__builtin__.type'>, ('traceback', '__builtin__'): <netref class '__builtin__.traceback'>, ('basestring', '__builtin__'): <netref class '__builtin__.basestring'>, ('bool', '__builtin__'): <netref class '__builtin__.bool'>, ('builtin_function_or_method', '__builtin__'): <netref class '__builtin__.builtin_function_or_method'>}

The cache of built-in netref classes (each of the types listed in _builtin_types). These are shared between all RPyC connections

Async

exception rpyc.core.async.AsyncResultTimeout[source]

an exception that represents an AsyncResult that has timed out

class rpyc.core.async.AsyncResult(conn)[source]

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()[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 AsyncResultTimeout exception 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 None for unlimited time

Parameters:timeout – the expiry time in seconds or None
ready

Indicates whether the result has arrived

error

Indicates whether the returned result is an exception

expired

Indicates whether the AsyncResult has expired

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.