def __init__(self, wait_interval=0.01, graceful_shutdown_timeout=60):
        """Creates the ServiceManager object

        :param wait_interval: time between each new process spawn
        :type wait_interval: float

        """

        if self._process_runner_already_created:
            raise RuntimeError("Only one instance of ServiceManager per "
                               "application is allowed")
        ServiceManager._process_runner_already_created = True
        super(ServiceManager, self).__init__()

        # We use OrderedDict to start services in adding order
        self._services = collections.OrderedDict()
        self._running_services = collections.defaultdict(dict)
        self._forktimes = []
        self._graceful_shutdown_timeout = graceful_shutdown_timeout
        self._wait_interval = wait_interval

        self._dead = threading.Event()
        # NOTE(sileht): Set it on startup, so first iteration
        # will spawn initial workers
        self._got_sig_chld = threading.Event()
        self._got_sig_chld.set()

        self._child_supervisor = None

        self._hooks = {
            'terminate': [],
            'reload': [],
            'new_worker': [],
            'dead_worker': [],
        }

        _utils.setproctitle("%s: master process [%s]" %
                            (_utils.get_process_name(), " ".join(sys.argv)))

        # Try to create a session id if possible
        try:
            os.setsid()
        except (OSError, AttributeError):
            pass

        self._death_detection_pipe = multiprocessing.Pipe(duplex=False)

        signal.signal(signal.SIGINT, self._fast_exit)
        if os.name == 'posix':
            signal.signal(signal.SIGCHLD, self._signal_catcher)
def __init__ ( self , wait_interval = 0.01 , graceful_shutdown_timeout = 60 ) : if self . _process_runner_already_created : raise RuntimeError ( "Only one instance of ServiceManager per " "application is allowed" ) ServiceManager . _process_runner_already_created = True super ( ServiceManager , self ) . __init__ ( ) self . _services = collections . OrderedDict ( ) self . _running_services = collections . defaultdict ( dict ) self . _forktimes = [ ] self . _graceful_shutdown_timeout = graceful_shutdown_timeout self . _wait_interval = wait_interval self . _dead = threading . Event ( ) self . _got_sig_chld = threading . Event ( ) self . _got_sig_chld . set ( ) self . _child_supervisor = None self . _hooks = { 'terminate' : [ ] , 'reload' : [ ] , 'new_worker' : [ ] , 'dead_worker' : [ ] , } _utils . setproctitle ( "%s: master process [%s]" % ( _utils . get_process_name ( ) , " " . join ( sys . argv ) ) ) try : os . setsid ( ) except ( OSError , AttributeError ) : pass self . _death_detection_pipe = multiprocessing . Pipe ( duplex = False ) signal . signal ( signal . SIGINT , self . _fast_exit ) if os . name == 'posix' : signal . signal ( signal . SIGCHLD , self . _signal_catcher )
Creates the ServiceManager object

        :param wait_interval: time between each new process spawn
        :type wait_interval: float