start_consumers_for_queue

    :param prefix_name:
    :param num_workers:
    :param tasks:
    :param queue_to_consume:
    :param shutdown_msg:
    :param consumer_class:
    :param need_response:
    :param callback:
15236
def start_consumers_for_queue(prefix_name="worker",
                              num_workers=2,
                              tasks=None,
                              queue_to_consume=None,
                              shutdown_msg="SHUTDOWN",
                              consumer_class=None,
                              need_response=False,
                              callback=None):
    

    consumers = []

    if not consumer_class:
        log.error("Please provide a consumer_class arg")
        log.error("  like: network_pipeline.packet_consumer.PacketConsumer")
        return consumers

    if not tasks:
        log.error("Missing tasks")
        return consumers

    if not queue_to_consume:
        log.error("Missing queue")
        return consumers

    # Establish communication queues
    log.info(("Creating consumers={} for cores={}")
             .format(multiprocessing.cpu_count(),
                     num_workers))

    for i in range(num_workers):
        consumers.append(consumer_class(
                            "{}-{}".format(prefix_name,
                                           i + 1),
                            tasks,
                            queue_to_consume,
                            shutdown_msg=shutdown_msg,
                            need_response=need_response,
                            callback=callback))

    log.info("Starting consumers={}".format(len(consumers)))
    for w in consumers:
        w.start()

    return consumers
143126
def start(self):
        
        if not self.connection:
            self.create_connection()
        while True:
            try:
                channel = self.connection.channel()
                channel.queue.declare('simple_queue')
                channel.basic.consume(self, 'simple_queue', no_ack=False)
                channel.start_consuming()
                if not channel.consumer_tags:
                    channel.close()
            except amqpstorm.AMQPError as why:
                LOGGER.exception(why)
                self.create_connection()
            except KeyboardInterrupt:
                self.connection.close()
                break
691293
async def monitor_start(self, monitor):
        '''
        '''
        cfg = self.cfg
        if (not platform.has_multiprocessing_socket or
                cfg.concurrency == 'thread'):
            cfg.set('workers', 0)
        servers = await self.binds(monitor)
        if not servers:
            raise ImproperlyConfigured('Could not open a socket. '
                                       'No address to bind to')
        addresses = []
        for server in servers.values():
            addresses.extend(server.addresses)
        self.cfg.addresses = addresses
747355
def start_service
      begin
        @registry = ActorRegistry.new
        @dispatchers = create_dispatchers
        # Creating sender now but for HTTP mode it is not really usable until setup_http
        # is called by the code loaded for this application in load_actors
        @sender = create_sender
        load_actors
        setup_traps
        setup_status
        if @mode != :http
          setup_non_delivery
          setup_queues
        end
        @history.update("run")
        start_console if @options[:console] && !@options[:daemonize]
        EM.next_tick { @options[:ready_callback].call } if @options[:ready_callback]
        @client.listen(nil) { |e| handle_event(e) } if @mode == :http

        # Need to keep reconnect interval at least :connect_timeout in size,
        # otherwise connection_status callback will not timeout prior to next
        # reconnect attempt, which can result in repeated attempts to setup
        # queues when finally do connect
        setup_status_checks([@options[:check_interval], @options[:connect_timeout]].max)
      rescue StandardError => e
        terminate("failed service startup", e)
      end
      true
    end
884234
def start(self):
        
        t=threading.Thread(target=self._consume)
        t.start()
513605
def start(self):
        '''
        
        '''
        log.debug('Creating the consumer using the bootstrap servers: %s and the group ID: %s',
                  self.bootstrap_servers,
                  self.group_id)
        try:
            self.consumer = kafka.KafkaConsumer(bootstrap_servers=self.bootstrap_servers,
                                                group_id=self.group_id)
        except kafka.errors.NoBrokersAvailable as err:
            log.error(err, exc_info=True)
            raise ListenerException(err)
        log.debug('Subscribing to the %s topic', self.topic)
        self.consumer.subscribe(topics=[self.topic])
875111
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".')
        # 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)
360293
def initialize_tasks(self):
        
        # Add a poison pill to shutdown each process.
        self.tasks = chain(self.iterable, [POISON_PILL] * self.num_processes)
        for task in islice(self.tasks, Q_MAX_SIZE):
            log.debug('Putting %s on queue', task)
            self.task_queue.put(task)
683053
def initiate_tasks(self):
        
        self.tasks_classes = TaskLoader().load_tasks(
            paths=self.configuration[Configuration.ALGORITHM][Configuration.TASKS][Configuration.PATHS])
196156
def start_parallel(self):
        
        self.num_processes = get_num_processes()

        self.task_queue = multiprocessing.Queue(maxsize=Q_MAX_SIZE)
        self.result_queue = multiprocessing.Queue()
        self.log_queue = multiprocessing.Queue()

        # Used to signal worker processes when a result is found that allows
        # the computation to terminate early.
        self.complete = multiprocessing.Event()

        args = (self.compute, self.task_queue, self.result_queue,
                self.log_queue, self.complete) + self.context
        self.processes = [
            multiprocessing.Process(target=self.worker, args=args, daemon=True)
            for i in range(self.num_processes)]

        for process in self.processes:
            process.start()

        self.log_thread = LogThread(self.log_queue)
        self.log_thread.start()

        self.initialize_tasks()
1013845
def _start_consumer(self, consumer):
        
        thread = threading.Thread(target=consumer.start,
                                  args=(self._connection,))
        thread.daemon = True
        thread.start()
830834
def on_startup_error(self, error):
        
        LOGGER.critical('Could not start %s: %s', self.consumer_name, error)
        self.set_state(self.STATE_STOPPED)
577944
def setup_consumers(self):
        
        if not self.consumer_cfg:
            LOGGER.warning('No consumers are configured')
        for name in self.consumer_cfg.keys():
            self.consumers[name] = self.new_consumer(
                self.consumer_cfg[name], name)
            self.start_processes(name, self.consumers[name].qty)
1215388
def pusher(task_queue, event, broker=None):
    
    if not broker:
        broker = get_broker()
    logger.info(_('{} pushing tasks at {}').format(current_process().name, current_process().pid))
    while True:
        try:
            task_set = broker.dequeue()
        except Exception as e:
            logger.error(e, traceback.format_exc())
            # broker probably crashed. Let the sentinel handle it.
            sleep(10)
            break
        if task_set:
            for task in task_set:
                ack_id = task[0]
                # unpack the task
                try:
                    task = SignedPackage.loads(task[1])
                except (TypeError, BadSignature) as e:
                    logger.error(e, traceback.format_exc())
                    broker.fail(ack_id)
                    continue
                task['ack_id'] = ack_id
                task_queue.put(task)
            logger.debug(_('queueing from {}').format(broker.list_key))
        if event.is_set():
            break
    logger.info(_("{} stopped pushing tasks").format(current_process().name))
1373944
@SafeVarargs
    public final ServerListenerBuilder addStartingCallbacks(Consumer<? super Server>... consumers) {
        return addStartingCallbacks(Arrays.asList(consumers));
    }
1162599
def start
      queue = ::Queue.new

      @thread = Thread.start do
        @listener_redis.subscribe(@channel, @my_channel) do |on|
          on.subscribe do |channel|
            queue.push(:subscribed) if channel == @channel
          end

          on.message do |channel, message|
            handle_message(channel, message)
          end
        end
      end

      queue.pop
    end
761490
async def consume_queue(self, subscriber: AbstractSubscriber) -> None:

        

        queue_name = subscriber.name
        topics = subscriber.requested_topics

        if queue_name in self._known_queues:
            raise exceptions.ConsumerError("Queue '%s' already being consumed" % queue_name)

        await self._declare_queue(queue_name)

        # TODO: There is a lot of room to improvement here. Figure out routing done the right way
        for key in topics:
            self._routing.setdefault(key, set())
            if subscriber in self._routing[key]:
                logger.warning("Subscriber '%s' already receiving routing_key '%s'", subscriber, key)
                break
            await self._bind_key_to_queue(key, queue_name)
            self._routing[key].add(subscriber)

        logger.info("Consuming queue '%s'", queue_name)
        await asyncio.wait_for(
            self._channel.basic_consume(callback=self._on_message, queue_name=queue_name),
            timeout=10
        )
        self._add_to_known_queue(queue_name)