RMI

The BNDL RMI module builds on bndl.net to allow for Remote Method Invocations.

The implementation is rather straight forward: RMIPeerNode provides is the means to send and receive Request and Response Methods. Requests are targeting a method of the remote node by name. It is simply looked up by getattr.

class bndl.rmi.node.RMINode(name=None, addresses=None, seeds=None, loop=None)[source]

Bases: bndl.net.node.Node

A bndl.net.Node which expects it’s peers to support remote method invocation as implemented in RMIPeerNode.

class bndl.rmi.node.RMIPeerNode(*args, **kwargs)[source]

Bases: bndl.net.peer.PeerNode

class bndl.rmi.node.Invocation(peer, name)[source]

Bases: object

Invocation of a method on a PeerNode.

with_timeout(timeout)[source]

Apply a time out in performing the remote method invocation. When the time out expires concurrent.futures.TimeoutError is raised. :param timeout:

Messages

class bndl.rmi.messages.Request(**kwargs)[source]

Bases: bndl.net.messages.Message

A request for a peer RMI node. It contains a request id (to which the Reponse must refer), the name of the method to be invoked, and the positional and keyword arguments for invocation.

class bndl.rmi.messages.Response(**kwargs)[source]

Bases: bndl.net.messages.Message

A response to a Request. It refers to the id of the request and either contains a value if the invoked method returned normally or an exception if it raised one.

Exceptions

exception bndl.rmi.exceptions.InvocationException[source]

Bases: Exception

Exception indicating a RMI failed. This exception is ‘raised from’ a ‘reconstructed’ exception as raised in the remote method

bndl.rmi.exceptions.root_exc(exc)[source]

Returns the __cause__ of exc if exc is an InvocationException or just exc otherwise.

Can be used when both local and remote exceptions need to be handled and their semantics are the same (whether the exception was raised locally or on a remote worker doesn’t matter).

Parameters:exc – The exception which _might_ be an InvocationException