pyrolab.manager.DaemonRunner

Contents

pyrolab.manager.DaemonRunner#

class DaemonRunner(*args, name: str, daemonconfig: DaemonConfiguration, serviceconfigs: Dict[str, ServiceConfiguration], msg_queue: Queue, shared_uris: dict[str, URI], msg_polling: float = 1.0, **kwargs)[source]#

Bases: Process

A process for running server daemons using Python’s multiprocessing.

Advantages of using a ResourceRunner include the fact that if a server dies or hangs up, the entire program doesn’t stall or need to be restarted, just the process that contained the server. Thus errors can be handled and servers autonomously restarted and managed.

Other advantages should include speed; splitting servers across processors means that resource-heavy instruments won’t bog down adjacent instruments.

Parameters:
namestr

The name of the daemon being run.

daemonconfigDaemonConfiguration

The configuration for the daemon.

serviceconfigsDict[str, ServiceConfiguration]

The configuration for the services belonging to the given daemon.

msg_queuemultiprocessing.Queue

A message queue. ResourceRunner listens for when “None” is placed in the queue, which is a sentinel value to shutdown the process.

msg_pollingfloat, optional

The time in seconds between polling the message queue.

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

close()

Close the Process object.

is_alive()

Return whether process is alive

join([timeout])

Wait until child process terminates

kill()

Terminate process; sends SIGKILL signal or uses TerminateProcess()

process_message_queue()

A message handler.

run()

Creates and runs the child process.

setup_daemon()

Locates and loads the Daemon class, adds Pyro's behavior, and registers the hosted object with the Daemon.

start()

Start child process

stay_alive()

A callback listener; if the sentinel value None is placed in the message queue, returns True signifying a shutdown signal has been received.

terminate()

Terminate process; sends SIGTERM signal or uses TerminateProcess()