execute callback for all queued messages.
 This is called by {Node#spin_once}.
 It checks all queues of connections and callback for all messages.
 @return [Bool] some message has come or not.
501279
def process_queue #:nodoc:
      messages_come = false
      @connections.each do |connection|
        while not connection.msg_queue.empty?
          msg = connection.msg_queue.pop
          messages_come = true
          if @callback
            @callback.call(msg)
          end
        end
      end
      messages_come
    end
98695
def run
      loop do
        link, referer, depth = @link_queue.deq

        break if link == :END

        @http.fetch_pages(link, referer, depth).each { |page| @page_queue << page }

        delay
      end
    end
1027299
def do_callback(self, pkt):
        
        callback, parser = self.get_callback_parser(pkt)

        if asyncio.iscoroutinefunction(callback):
            self.loop.call_soon_threadsafe(self._do_async_callback,
                                           callback, parser)
        else:
            self.loop.call_soon(callback, parser)
117510
def run(self):
        ''''''
        # We left-append rather than emit (right-append) because some message
        # may have been already queued for execution before the director runs.
        global_event_queue.appendleft((INITIATE, self, (), {}))
        while global_event_queue:
            self.process_event(global_event_queue.popleft())
841854
def wait(self):
        
        if not self._patterns:
            raise RuntimeError('Listener has nothing to capture')

        while 1:
            msg = self._queue.get(block=True)

            if any(map(lambda p: filtering.match_all(msg, p), self._patterns)):
                return msg
1198396
def _run_done_callbacks(self):
        ''' 
        '''
        with self._callbacks_lock:
            for callback in self._done_callbacks:
                try:
                    callback()
                # We do not want a callback interrupting the process, especially
                # in the failure cleanups. So log and catch, the excpetion.
                except Exception as ex:
                    logger.error("Exception: %s" % str(ex))
                    logger.error("Exception raised in %s." % callback, exc_info=True)

            self._done_callbacks = []
121570
def execute(*args, &task)
      if ensure_capacity?
        @scheduled_task_count += 1
        @queue << [args, task]
      else
        if @max_queue != 0 && @queue.length >= @max_queue
          handle_fallback(*args, &task)
        end
      end
      prune_pool
    end
405221
def process_events
      until @dead
        @mutex.synchronize do
          while @queue.empty?
            break if @dead
            @not_empty.wait(@mutex)
          end
          event = @queue.pop
          break unless event
          notify_listeners(event)
          event.dispatch
        end
      end
    rescue Exception => ex
      Logger.error "Error while running event: #{Logger.format_error(ex)}"
    end
231693
def process_messages_loop(self):
        
        self.receiving_messages = True
        try:
            self.process_messages_loop_internal()
        except pika.exceptions.ConnectionClosed as ex:
            logging.error("Connection closed {}.".format(ex))
            raise
132591
def done?
      return (
        get_jobs_by_status(Executor::STATUS_NONE).size == 0 &&
        get_jobs_by_status(Executor::STATUS_RUNNING).size == 0 &&
        get_jobs_by_status(Executor::STATUS_DONE).size > 0
      )
    end
1308853
def flush( queue_name )
      # It can take a long time to flush all of the messages
      # on a server, so we'll set the read timeout to something
      # much higher than usual.
      connection.with_additional_read_timeout(60) do
        req  = KJess::Request::Flush.new( :queue_name => queue_name )
        resp = send_recv( req )
        return KJess::Response::End === resp
      end
    end
950921
async def execute(self, *, return_exceptions=False):
        
        assert not self._done, "Pipeline already executed. Create new one."
        self._done = True

        if self._pipeline:
            if isinstance(self._pool_or_conn, AbcPool):
                async with self._pool_or_conn.get() as conn:
                    return await self._do_execute(
                        conn, return_exceptions=return_exceptions)
            else:
                return await self._do_execute(
                    self._pool_or_conn,
                    return_exceptions=return_exceptions)
        else:
            return await self._gather_result(return_exceptions)
1110439
def _check_events(tk):
    """"""

    used = False
    try:
        # Process all enqueued events, then exit.
        while True:
            try:
                # Get an event request from the queue.
                method, args, kwargs, response_queue = tk.tk._event_queue.get_nowait()
            except queue.Empty:
                # No more events to process.
                break
            else:
                # Call the event with the given arguments, and then return
                # the result back to the caller via the response queue.
                used = True
                if tk.tk._debug >= 2:
                    print('Calling event from main thread:', method.__name__, args, kwargs)
                try:
                    response_queue.put((False, method(*args, **kwargs)))
                except SystemExit:
                    raise  # Raises original SystemExit
                except Exception:
                    # Calling the event caused an exception; return the
                    # exception back to the caller so that it can be raised
                    # in the caller's thread.
                    from sys import exc_info  # Python 2 requirement
                    ex_type, ex_value, ex_tb = exc_info()
                    response_queue.put((True, (ex_type, ex_value, ex_tb)))
    finally:
        # Schedule to check again. If we just processed an event, check
        # immediately; if we didn't, check later.
        if used:
            tk.after_idle(_check_events, tk)
        else:
            tk.after(tk.tk._check_period, _check_events, tk)
1099968
def process_messages_loop_internal(self):
        
        logging.info("Starting work queue loop.")
        self.connection.receive_loop_with_callback(self.queue_name, self.process_message)
208777
def callback(event, buffer = nil, start = nil, the_end = nil)
      return if !start.nil? && start == the_end
      if @callbacks.has_key? event
        @callbacks[event].call(buffer, start, the_end)
      end
    end
658624
def perform
      unless @threads.any? { |t| t.alive? }
        @values.start!
        @size.times do
          @threads << Thread.new do
            while job = @queue.pop
              if job == :END_OF_WORK
                break
              else
                @values.push *job[1], &job[0]
              end
            end
          end
        end
      end
    end
1297218
def do_callbacks(callback_type, object, options = {})
      return if $bot[:callbacks][callback_type].nil?
      $bot[:callbacks][callback_type].each do |c|
        c[:block].call object, options
      end
    end