Base

Interface definition and base implementation for all subprocess managers.

Interface

class servermgr.base.ManagerInterface[source]

This abstract class defines the interface implemented by all Managers.

health()[source]

Check the health of the worker subprocess.

Raises :WorkerError if the worker subprocess is not responding.
ready_wait(timeout=10.0)[source]

Wait for the worker to be ready to handle requests.

Parameters:
  • timeout (float, seconds) – Give the server this many seconds to start. If the timeout expires before the server has started, kill the server and raise WorkerError.
Raises :

WorkerError if the worker is not ready within the time limit.

start(wait=True, timeout=10.0)[source]

Start the worker subprocess.

Parameters:
  • wait – If true, call self.ready_wait() after starting the subprocess.
  • timeout (float, number of seconds) – When calling ready_wait(), use this timeout value.
stop(wait=True)[source]

Stop the worker subprocess.

Parameters:
  • wait (boolean) – If True, wait for the worker to exit.
wait()[source]

Wait for the worker process to exit.

Exceptions

exception servermgr.base.WorkerError(exception, *args, **kwargs)[source]

Exception raised when a Worker fails to start or fails to respond.

Utility Functions

servermgr.base.address_in_use(host, port)[source]

Check to see if there is a listener on host:port.

Parameters:
  • host (string) – the interface to check;
  • port (int) – the post to check;
Returns:

True if there is a listener, else False.

servermgr.base.address_free_check(host, port)[source]

Raise an exception if host:port is in use.

Parameters:
  • host (string) – the interface to check;
  • port (int) – the post to check;
Raises :

WorkerError if the address is in use.

Classes

class servermgr.base.Manager(name='<unnamed>', **kwargs)[source]
Parameters:
  • name – Name of manager, displayed in error and log messages.
  • kwargs – Any other keyword args will be stored in self.kwargs.

This is the base implementation of the Manager class.

Implementations are provided for the following methods:

  • ready_wait()
  • stop()
  • wait()

The following methods must be implemented by the subclass:

  • health()
  • start()
health()[source]

Check the worker subprocess health.

Raises :NotImplementedError must be implemented by subclass.
process[source]

Return the process object.

ready_wait(timeout=10.0, verbose=False)[source]

Wait until the worker subprocess is responding to requests.

Parameters:
  • timeout (float, seconds) – Give the server this many seconds to start. If the timeout expires before the server has started, kill the server and raise WorkerError.
Raises :

WorkerError if the worker is not ready within the time limit.

Raises :

WorkerError if there is no subprocess.

start(wait=True, timeout=10.0)[source]

Start the worker subprocess.

Raises :NotImplementedError must be implemented by subclass.
stop(wait=True)[source]

Terminate the worker subprocess.

Parameters:
  • wait (boolean) – If True, wait for the worker to exit.
wait()[source]

Wait for the worker process to exit.

Table Of Contents

Previous topic

Managers

Next topic

Nginx

This Page