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 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_XXX
members ofrpyc.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__
ofnetref
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: - conn – the
rpyc.core.protocol.Connection
instance - oid – the unique object ID of the remote object
- conn – the
-
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
= {('BaseException', 'builtins'): <netref class 'builtins.BaseException'>, ('Exception', 'builtins'): <netref class 'builtins.Exception'>, ('NoneType', 'builtins'): <netref class 'builtins.NoneType'>, ('bool', 'builtins'): <netref class 'builtins.bool'>, ('builtin_function_or_method', 'builtins'): <netref class 'builtins.builtin_function_or_method'>, ('bytearray', 'builtins'): <netref class 'builtins.bytearray'>, ('bytes', 'builtins'): <netref class 'builtins.bytes'>, ('code', 'builtins'): <netref class 'builtins.code'>, ('complex', 'builtins'): <netref class 'builtins.complex'>, ('dict', 'builtins'): <netref class 'builtins.dict'>, ('float', 'builtins'): <netref class 'builtins.float'>, ('frame', 'builtins'): <netref class 'builtins.frame'>, ('frozenset', 'builtins'): <netref class 'builtins.frozenset'>, ('function', 'builtins'): <netref class 'builtins.function'>, ('generator', 'builtins'): <netref class 'builtins.generator'>, ('int', 'builtins'): <netref class 'builtins.int'>, ('list', 'builtins'): <netref class 'builtins.list'>, ('list_iterator', 'builtins'): <netref class 'builtins.list_iterator'>, ('memoryview', 'builtins'): <netref class 'builtins.memoryview'>, ('method', 'builtins'): <netref class 'builtins.method'>, ('method-wrapper', 'builtins'): <netref class 'builtins.method-wrapper'>, ('module', 'builtins'): <netref class 'builtins.module'>, ('object', 'builtins'): <netref class 'builtins.object'>, ('range_iterator', 'builtins'): <netref class 'builtins.range_iterator'>, ('set', 'builtins'): <netref class 'builtins.set'>, ('set_iterator', 'builtins'): <netref class 'builtins.set_iterator'>, ('slice', 'builtins'): <netref class 'builtins.slice'>, ('str', 'builtins'): <netref class 'builtins.str'>, ('traceback', 'builtins'): <netref class 'builtins.traceback'>, ('tuple', 'builtins'): <netref class 'builtins.tuple'>, ('tuple_iterator', 'builtins'): <netref class 'builtins.tuple_iterator'>, ('type', 'builtins'): <netref class 'builtins.type'>, ('wrapper_descriptor', 'builtins'): <netref class 'builtins.wrapper_descriptor'>}¶ 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 timeParameters: 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.
-