def start(self):
        """
        Start all consumer processes and register signal handlers.
        """
        if self.huey.immediate:
            raise ConfigurationError(
                'Consumer cannot be run with Huey instances where immediate '
                'is enabled. Please check your configuration and ensure that '
                '"huey.immediate = False".')
        # Log startup message.
        self._logger.info('Huey consumer started with %s %s, PID %s at %s',
                          self.workers, self.worker_type, os.getpid(),
                          self.huey._get_timestamp())
        self._logger.info('Scheduler runs every %s second(s).',
                          self.scheduler_interval)
        self._logger.info('Periodic tasks are %s.',
                          'enabled' if self.periodic else 'disabled')

        self._set_signal_handlers()

        msg = ['The following commands are available:']
        for command in self.huey._registry._registry:
            msg.append('+ %s' % command)

        self._logger.info('\n'.join(msg))

        # We'll temporarily ignore SIGINT and SIGHUP (so that it is inherited
        # by the child-processes). Once the child processes are created, we
        # restore the handler.
        original_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
        if hasattr(signal, 'SIGHUP'):
            original_sighup_handler = signal.signal(signal.SIGHUP, signal.SIG_IGN)

        self.scheduler.start()
        for _, worker_process in self.worker_threads:
            worker_process.start()

        signal.signal(signal.SIGINT, original_sigint_handler)
        if hasattr(signal, 'SIGHUP'):
            signal.signal(signal.SIGHUP, original_sighup_handler)
def start ( self ) : if self . huey . immediate : raise ConfigurationError ( 'Consumer cannot be run with Huey instances where immediate ' 'is enabled. Please check your configuration and ensure that ' '"huey.immediate = False".' ) self . _logger . info ( 'Huey consumer started with %s %s, PID %s at %s' , self . workers , self . worker_type , os . getpid ( ) , self . huey . _get_timestamp ( ) ) self . _logger . info ( 'Scheduler runs every %s second(s).' , self . scheduler_interval ) self . _logger . info ( 'Periodic tasks are %s.' , 'enabled' if self . periodic else 'disabled' ) self . _set_signal_handlers ( ) msg = [ 'The following commands are available:' ] for command in self . huey . _registry . _registry : msg . append ( '+ %s' % command ) self . _logger . info ( '\n' . join ( msg ) ) original_sigint_handler = signal . signal ( signal . SIGINT , signal . SIG_IGN ) if hasattr ( signal , 'SIGHUP' ) : original_sighup_handler = signal . signal ( signal . SIGHUP , signal . SIG_IGN ) self . scheduler . start ( ) for _ , worker_process in self . worker_threads : worker_process . start ( ) signal . signal ( signal . SIGINT , original_sigint_handler ) if hasattr ( signal , 'SIGHUP' ) : signal . signal ( signal . SIGHUP , original_sighup_handler )
Start all consumer processes and register signal handlers.