osbrain.nameserver
— osBrain nameserver logic¶
Implementation of name server.
-
class
osbrain.nameserver.
NameServer
(*args, **kwargs)¶ Bases:
Pyro4.naming.NameServer
Methods
agents
()List agents registered in the name server. async_shutdown
()Shutdown the name server. async_shutdown_agents
()Shutdown all agents registered in the name server. list
([prefix, regex, metadata_all, …])Retrieve the registered items as a dictionary name-to-URI. lookup
(name[, return_metadata])Lookup the given name, returns an URI if found. ping
()A simple test method to check if the name server is running correctly. register
(name, uri[, safe, metadata])Register a name with an URI. remove
([name, prefix, regex])Remove a registration. set_metadata
(name, metadata)update the metadata for an existing registration count -
agents
()¶ List agents registered in the name server.
-
async_shutdown
()¶ Shutdown the name server. All agents will be shutdown as well.
-
async_shutdown_agents
()¶ Shutdown all agents registered in the name server.
-
ping
()¶ A simple test method to check if the name server is running correctly.
-
-
class
osbrain.nameserver.
NameServerProcess
(addr=None)¶ Bases:
multiprocessing.context.Process
Name server class. Instances of a name server are system processes which can be run independently.
Attributes: - authkey
daemon
Return whether process is a daemon
exitcode
Return exit code of process or None if it has yet to stop
ident
Return identifier (PID) of process or None if it has yet to start
- name
pid
Return identifier (PID) of process or None if it has yet to start
sentinel
Return a file descriptor (Unix) or handle (Windows) suitable for waiting for process termination.
Methods
agents
()List agents registered in the name server. is_alive
()Return whether process is alive join
([timeout])Wait until child process terminates run
()Method to be run in sub-process; can be overridden in sub-class shutdown
()Shutdown the name server. shutdown_all
()Shutdown all agents registered in the name server. start
()Start child process terminate
()Terminate process; sends SIGTERM signal or uses TerminateProcess() -
agents
()¶ List agents registered in the name server.
-
run
()¶ Method to be run in sub-process; can be overridden in sub-class
-
shutdown
()¶ Shutdown the name server. All agents will be shutdown as well.
-
shutdown_all
()¶ Shutdown all agents registered in the name server.
-
start
()¶ Start child process
-
osbrain.nameserver.
random_nameserver_process
(host='127.0.0.1', port_start=10000, port_stop=20000, timeout=3.0)¶ Start a random NameServerProcess.
Parameters: - host : str, default is ‘127.0.0.1’
Host address where the name server will bind to.
- port_start : int
Lowest port number allowed.
- port_stop : int
Highest port number allowed.
Returns: - NameServerProcess
The name server process started.
-
osbrain.nameserver.
run_nameserver
(addr=None)¶ Ease the name server creation process.
This function will create a new nameserver, start the process and then run its main loop through a proxy.
Parameters: - addr : SocketAddress, default is None
Name server address.
Returns: - proxy
A proxy to the name server.