rsb.patterns¶
Contains communication pattern implementations.
For instance, RPC based on the basic participants rsb.Listener and
rsb.Informer.
Code author: jmoringe
Code author: jwienke
Classes
| 
 | Implements and makes available a method of a local server. | 
| 
 | Provide local methods to remote clients. | 
| 
 | Base class for methods of local or remote servers. | 
| 
 | Provides a pull model for fetching received events. | 
| 
 | Represents a method provided by a remote server. | 
| 
 | Represents remote servers in a way that allows using normal methods calls. | 
| 
 | Base class for local or remote servers. | 
Exceptions
| 
 | Represents an error when calling a remote method implementation. | 
- 
exception rsb.patterns.RemoteCallError(scope, method, error)¶
- Bases: - RuntimeError- Represents an error when calling a remote method implementation. - Code author: jmoringe - 
with_traceback()¶
- Exception.with_traceback(tb) – set self.__traceback__ to tb and return self. 
 - 
args¶
 - 
property method¶
 - 
property scope¶
 
- 
- 
class rsb.patterns.LocalMethod(scope, config, server, name, func, request_type, reply_type, allow_parallel_execution)¶
- Bases: - rsb.patterns.Method- Implements and makes available a method of a local server. - The actual behavior of methods is implemented by invoking arbitrary user-supplied callables. - Code author: jmoringe - 
activate()¶
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
classmethod get_connectors(direction, config)¶
 - 
make_informer()¶
 - 
make_listener()¶
 - 
property config¶
 - 
property informer¶
 - 
property listener¶
 - 
property name¶
 - 
property participant_id¶
 - 
property reply_type¶
 - 
property request_type¶
 - 
property scope¶
 - 
property server¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set 
 
 
- 
- 
class rsb.patterns.LocalServer(scope, config)¶
- Bases: - rsb.patterns.Server- Provide local methods to remote clients. - Objects of this class associate a collection of method objects which are implemented by callback functions with a scope under which these methods are exposed for remote clients. - Code author: jmoringe - Create a - LocalServerthat provides methods under a given scope.- Parameters
- scope – The scope under which the methods of the newly created server should be provided. 
- config – The transport configuration that should be used for communication performed by this server. 
 
- Type scope
- rsb.Scope 
- Type config
- rsb.ParticipantConfig 
 - See also - 
activate()¶
 - 
add_method(name, func, request_type=<class 'object'>, reply_type=<class 'object'>, allow_parallel_execution=False)¶
- Add a method named - namethat is implemented by- func.- Parameters
- name – The name of of the new method. 
- func – A callable object or a single argument that implements the desired behavior of the new method. 
- request_type – A type object indicating the type of request data passed to the method. 
- reply_type – A type object indicating the type of reply data of the method. 
- allow_parallel_execution – if set to True, the method will be called fully asynchronously and even multiple calls may enter the method in parallel. Also, no ordering is guaranteed anymore. 
 
- Type name
- str 
- Type request_type
- types.TypeType 
- Type allow_parallel_execution
- bool 
- Returns
- The newly created method. 
- Rtype
- LocalMethod 
 
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
classmethod get_connectors(direction, config)¶
 - 
get_method(name)¶
 - 
remove_method(method)¶
 - 
property config¶
 - 
property methods¶
 - 
property participant_id¶
 - 
property scope¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set 
 
 
- 
class rsb.patterns.Method(scope, config, server, name, request_type, reply_type)¶
- Bases: - rsb.Participant- Base class for methods of local or remote servers. - Objects of this class are methods which are associated to a local or remote server. Within a server, each method has a unique name. - This class is primarily intended as a superclass for local and remote method classes. - Code author: jmoringe - Create a new - Methodobject for the given name and server.- Parameters
- server – The remote or local server to which the method is associated. 
- name – The name of the method. Unique within a server. 
- request_type – The type of the request argument accepted by the method. 
- reply_type – The type of the replies produced by the method. 
 
- Type name
- str 
- Type request_type
- types.TypeType 
- Type reply_type
- types.TypeType 
 - 
activate()¶
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
classmethod get_connectors(direction, config)¶
 - 
property config¶
 - 
property informer¶
 - 
property listener¶
 - 
property name¶
 - 
property participant_id¶
 - 
property reply_type¶
 - 
property request_type¶
 - 
property scope¶
 - 
property server¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set 
 
 
- 
class rsb.patterns.Reader(scope, config, queue_size=-1)¶
- Bases: - rsb.Participant- Provides a pull model for fetching received events. - Clients need to continuously call the - read()method to fetch events. Internally, events are buffered in a queue until they are picked up by clients.- Code author: jwienke - Create a new - Readerfor- scope.- Parameters
- scope – The scope of the channel in which the new reader should participate. 
- config – The configuration that should be used by this - Reader.
- queue_size – Size of the internal queue of events that are held by the reader. If - readisn’t called fast enough the underlying transport will be blocked. Negative numbers create an infinite queue.
 
- Type scope
- Scope or accepted by Scope constructor 
- Type config
- ParticipantConfig 
- Type queue_size
- int 
 - See also - 
activate()¶
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
classmethod get_connectors(direction, config)¶
 - 
read(block=True)¶
- Read the next event from the wire. - Optionally blocks until an event is available. - Parameters
- block – If - True, block until the next event is received.
- Type block
- bool 
- Returns
- rsb.Event
- the received event 
 
 
 - 
property config¶
 - 
property participant_id¶
 - 
property scope¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set 
 
 
- 
class rsb.patterns.RemoteMethod(scope, config, server, name, request_type, reply_type)¶
- Bases: - rsb.patterns.Method- Represents a method provided by a remote server. - Method objects are callable like regular bound method objects. - Code author: jmoringe - 
activate()¶
 - 
asynchronous(arg=None)¶
- Call the method asynchronously and returns a - Future.- Calls the represented method with argument - arg, returning a- Futureinstance that can be used to retrieve the result.- If - argis an instance of- Event, the result of the method call is an- Eventcontaining the object returned by the remote method as payload. If- argis of any other type, the result is the payload of the method call is the object that was returned by the remote method.- The call to this method returns immediately, even if the remote method did produce a result yet. The returned - Futureinstance has to be used to retrieve the result.- Parameters
- arg – The argument object that should be passed to the remote method. A converter has to be available for the type of - arg.
- Returns
- A - Futureor- DataFutureinstance that can be used to check the success of the method call, wait for the result and retrieve the result.
- Rtype
- Future or DataFuture 
- Raises RemoteCallError
- If an error occurs before the remote was invoked. 
 - See also - __call__- Examples - >>> my_server.echo.asynchronous('bla') <Future running at 3054cd0> >>> my_server.echo.asynchronous('bla').get() 'bla' >>> my_server.echo.asynchronous(Event(scope=my_server.scope, ... data='bla', type=str)).get() Event[id = ..., data = 'bla', ...] 
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
classmethod get_connectors(direction, config)¶
 - 
make_informer()¶
 - 
make_listener()¶
 - 
property config¶
 - 
property informer¶
 - 
property listener¶
 - 
property name¶
 - 
property participant_id¶
 - 
property reply_type¶
 - 
property request_type¶
 - 
property scope¶
 - 
property server¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set 
 
 
- 
- 
class rsb.patterns.RemoteServer(scope, config)¶
- Bases: - rsb.patterns.Server- Represents remote servers in a way that allows using normal methods calls. - Code author: jmoringe - Create a new - RemoteServerproviding methods on the given scope.- Parameters
- scope – The common super-scope under which the methods of the remote created server are provided. 
- config – The configuration that should be used by this server. 
 
- Type scope
- rsb.Scope 
- Type config
- rsb.ParticipantConfig 
 - See also - 
activate()¶
 - 
add_method(method)¶
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
ensure_method(name)¶
 - 
classmethod get_connectors(direction, config)¶
 - 
get_method(name)¶
 - 
remove_method(method)¶
 - 
property config¶
 - 
property methods¶
 - 
property participant_id¶
 - 
property scope¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set 
 
 
- 
class rsb.patterns.Server(scope, config)¶
- Bases: - rsb.Participant- Base class for local or remote servers. - Objects of this class represent local or remote serves. A server is basically a collection of named methods that are bound to a specific scope. - This class is primarily intended as a superclass for local and remote server classes. - Code author: jmoringe - Create a - Serverthat provides methods under the given scope.- Parameters
- scope – The scope under which methods of the server are provided. 
- config – The transport configuration that should be used for communication performed by this server. 
 
- Type scope
- rsb.Scope 
- Type config
- rsb.ParticipantConfig 
 - 
activate()¶
 - 
add_method(method)¶
 - 
deactivate()¶
- Deactivate a participant by tearing down all connection logic. - This needs to be called in case you want to ensure that programs can terminate correctly. 
 - 
classmethod get_connectors(direction, config)¶
 - 
get_method(name)¶
 - 
remove_method(method)¶
 - 
property config¶
 - 
property methods¶
 - 
property participant_id¶
 - 
property scope¶
 - 
property transport_urls¶
- Return of list transport URLs for all used transports. - Returns
- Set of transport URLs. 
- Rtype
- set