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
([timeout])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
(timeout=10.0)¶ Shutdown the name server. All agents will be shutdown as well.
Parameters: - timeout : float, default is 10.
Timeout, in seconds, to wait for the agents to shutdown.
-
shutdown_agents
(timeout=10.0)¶ Shutdown all agents registered in the name server.
Parameters: - timeout : float, default is 10.
Timeout, in seconds, to wait for the agents to shutdown.
-
class
osbrain.proxy.
Proxy
(name, nsaddr=None, timeout=3.0, safe=None)¶ 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.
- safe : bool, default is None
Use safe calls by default. When not set, osbrain default’s
osbrain.config['SAFE']
is used.
Attributes: Methods
nsaddr
()Get the socket address of the name server. release
()Release the connection to the Pyro daemon. wait_for_running
([timeout])Wait until the agent is running. -
nsaddr
()¶ Get the socket address of the name server.
Returns: - SocketAddress
The socket address.
-
oneway
¶ Make the next remote method call be one way.
Returns: - The proxy itself.
-
release
()¶ Release the connection to the Pyro daemon.
-
safe
¶ Make the next remote method call be safe.
Returns: - The proxy itself.
-
unsafe
¶ Make the next remote method call be unsafe.
Returns: - The proxy itself.
-
wait_for_running
(timeout=3.0)¶ Wait until the agent is running.
Parameters: - timeout : float
Raise and exception if the agent is not running after this number of seconds. Use a negative value to wait forever.
Returns: - Proxy
The object itself.
Raises: - TimeoutError
If the agent is not running after the given timeout.
-
osbrain.proxy.
locate_ns
(nsaddr, timeout=3.0)¶ Locate a name server 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.