osbrain.nameserver — osBrain nameserver logic¶
Implementation of name server.
-
class
osbrain.nameserver.NameServer(*args, **kwargs)¶ Bases:
Pyro4.naming.NameServerMethods
agents()List agents registered in the name server. async_kill_agents(nsaddr)Kill all agents registered in the name server, with no mercy. async_shutdown_agents(nsaddr)Shutdown all agents registered in the name server. daemon_shutdown()Shutdown the name server daemon. 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_kill_agents(nsaddr)¶ Kill all agents registered in the name server, with no mercy.
-
async_shutdown_agents(nsaddr)¶ Shutdown all agents registered in the name server.
-
daemon_shutdown()¶ Shutdown the name server daemon.
-
ping()¶ A simple test method to check if the name server is running correctly.
-
-
class
osbrain.nameserver.NameServerProcess(addr=None, base=<class 'osbrain.nameserver.NameServer'>)¶ Bases:
multiprocessing.context.ProcessName server class. Instances of a name server are system processes which can be run independently.
Attributes: - authkey
daemonReturn whether process is a daemon
exitcodeReturn exit code of process or
Noneif it has yet to stopidentReturn identifier (PID) of process or
Noneif it has yet to start- name
pidReturn identifier (PID) of process or
Noneif it has yet to startsentinelReturn 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()Begin execution of the name server process and start the main loop. shutdown()Shutdown the name server. shutdown_all()Shutdown all agents registered in the name server. start()Start the system process. terminate()Terminate process; sends SIGTERM signal or uses TerminateProcess() -
agents()¶ List agents registered in the name server.
-
run()¶ Begin execution of the name server process and start the main loop.
-
shutdown()¶ Shutdown the name server. All agents will be shutdown as well.
-
shutdown_all()¶ Shutdown all agents registered in the name server.
-
start()¶ Start the system process.
Raises: - RuntimeError
If an error occurred when initializing the daemon.
-
osbrain.nameserver.random_nameserver_process(host='127.0.0.1', port_start=10000, port_stop=20000, timeout=3.0, base=<class 'osbrain.nameserver.NameServer'>)¶ 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, base=<class 'osbrain.nameserver.NameServer'>)¶ 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.