pyrolab.api#

Importing pyrolab.api or any object from it has one (useful) side effect. If a configuration file exists (has been set through the CLI), it will load and set PyroLab to use the first listed nameserver configuration. Functions such as pyrolab.api.locate_ns() will therefore find the nameserver without needing to pass any arguments, such as the hostname of the nameserver.

Services#

Wrappers#

expose(method_or_class: _T) _T[source]#

Decorator to mark a method or class to be exposed for remote calls. You can apply it to a method or a class as a whole. If you need to change the default instance mode or instance creator, also use a @behavior decorator.

behavior(instance_mode: str = 'session', instance_creator: Callable | None = None) Callable[source]#

Decorator to specify the server behavior of your Pyro class.

oneway(method: Callable) Callable[source]#

decorator to mark a method to be oneway (client won’t wait for a response)

Classes#

Server Daemon#

Functions#

locate_ns(host: str | IPv4Address | IPv6Address = '', port: int | None = None, broadcast: bool = True) client.Proxy[source]#

Get a proxy for a name server somewhere in the network.

start_ns(cfg: NameServerConfiguration = None)[source]#

Utility fuction to quickly get a Nameserver daemon to be used in your own event loops.

Returns:
nameserverUri, nameserverDaemon, broadcastServer

A tuple containing three pieces of information.

start_ns_loop(cfg: ~pyrolab.configure.NameServerConfiguration, loop_condition: ~typing.Callable = <function <lambda>>) None[source]#

Utility function that starts a new NameServer and enters its requestloop.

This function is a reimplemntation of the Pyro5.nameserver.start_ns_loop that allows for a loop condition to kill the loop. Alternatively, the loop can be shut down using ctrl+c.

Parameters:
cfgNameserverConfiguration

The configuration object for the nameserver.

loop_conditioncallable, optional

A callable that returns a boolean value. If the value is True, the loop will continue. If the value is False, the loop will stop. Defaults to lambda: True.

serve(objects: Dict[Any, str], host: str | IPv4Address | IPv6Address | None = None, port: int = 0, daemon: Daemon | None = None, use_ns: bool = True, verbose: bool = True) None[source]#

Basic method to fire up a daemon (or supply one yourself). objects is a dict containing objects to register as keys, and their names (or None) as values. If ns is true they will be registered in the naming server as well, otherwise they just stay local. If you need to publish on a unix domain socket, or require finer control of the daemon’s behavior, you can’t use this shortcut method. Create a Daemon yourself and use its appropriate methods. See the documentation on ‘publishing objects’ (in chapter: Servers) for more details.

Classes#

Client#

Classes#

class Proxy(uri, connected_socket=None)[source]#

Bases: object

Pyro proxy for a remote object. Intercepts method calls and dispatches them to the remote object.

_pyroBind()[source]#

Bind this proxy to the exact object from the uri. That means that the proxy’s uri will be updated with a direct PYRO uri, if it isn’t one yet. If the proxy is already bound, it will not bind again.

_pyroRelease()[source]#

release the connection to the pyro daemon

_pyroReconnect(tries=100000000)[source]#

(Re)connect the proxy to the daemon containing the pyro object which the proxy is for. In contrast to the _pyroBind method, this one first releases the connection (if the proxy is still connected) and retries making a new connection until it succeeds or the given amount of tries ran out.

_pyroValidateHandshake(response)[source]#

Process and validate the initial connection handshake response data received from the daemon. Simply return without error if everything is ok. Raise an exception if something is wrong and the connection should not be made.

_pyroTimeout#

The timeout in seconds for calls on this proxy. Defaults to None. If the timeout expires before the remote method call returns, Pyro will raise a Pyro5.errors.TimeoutError

_pyroMaxRetries#

Number of retries to perform on communication calls by this proxy, allows you to override the default setting.

_pyroSerializer#

Name of the serializer to use by this proxy, allows you to override the default setting.

_pyroHandshake#

The data object that should be sent in the initial connection handshake message. Can be any serializable object.

_pyroLocalSocket#

The socket that is used locally to connect to the remote daemon. The format depends on the address family used for the connection, but usually for IPV4 connections it is the familiar (hostname, port) tuple. Consult the Python documentation on socket families for more details

Configuration#

Functions#

Classes#