osbrain.proxy — osBrain proxy logic

Implementation of proxy-related features.

class osbrain.proxy.NSProxy(nsaddr=None, timeout=3)

Bases: Pyro4.core.Proxy

A proxy to access a name server.

Parameters:
nsaddr : SocketAddress, str

Name server address.

timeout : float

Timeout, in seconds, to wait until the name server is discovered.

Methods

addr([agent_alias, address_alias]) Return the name server address or the address of an agent’s socket.
proxy(name[, timeout]) Get a proxy to access an agent registered in the name server.
release() Release the connection to the Pyro daemon.
shutdown() Shutdown the name server.
shutdown_agents([timeout]) Shutdown all agents registered in the name server.
addr(agent_alias=None, address_alias=None)

Return the name server address or the address of an agent’s socket.

Parameters:
agent_alias : str, default is None

The alias of the agent to retrieve its socket address.

address_alias : str, default is None

The alias of the socket address to retrieve from the agent.

Returns:
SocketAddress or AgentAddress

The name server or agent’s socket address.

proxy(name, timeout=3.0)

Get a proxy to access an agent registered in the name server.

Parameters:
name : str

Proxy name, as registered in the name server.

timeout : float

Timeout, in seconds, to wait until the agent is discovered.

Returns:
Proxy

A proxy to access an agent registered in the name server.

release()

Release the connection to the Pyro daemon.

shutdown()

Shutdown the name server. All agents will be shutdown as well.

shutdown_agents(timeout=3.0)

Shutdown all agents registered in the name server.

Parameters:
timeout : float, default is 3.

Timeout, in seconds, to wait for the agents to shutdown.

class osbrain.proxy.Proxy(name, nsaddr=None, timeout=3.0)

Bases: Pyro4.core.Proxy

A proxy to access remote agents.

Parameters:
name : str

Proxy name, as registered in the name server.

nsaddr : SocketAddress, str

Name server address.

timeout : float

Timeout, in seconds, to wait until the agent is discovered.

Methods

pyro_addr()
Returns:
release() Release the connection to the Pyro daemon.
pyro_addr()
Returns:
SocketAddress

The socket address of the Pyro server.

release()

Release the connection to the Pyro daemon.

osbrain.proxy.locate_ns(nsaddr, timeout=3)

Locate a name server (ping) to ensure it actually exists.

Parameters:
nsaddr : SocketAddress

The address where the name server should be up and running.

timeout : float

Timeout in seconds before aborting location.

Returns:
nsaddr

The address where the name server was located.

Raises:
NamingError

If the name server could not be located.