Is NSQ running and have space to receive messages?
977320
def _is_ready(self, topic_name):
        '''
        
        '''
        url = 'http://%s/stats?format=json&topic=%s' % (self.nsqd_http_address, topic_name)
        #Cheacking for ephmeral channels
        if '#' in topic_name:
            topic_name, tag =topic_name.split("#", 1)

        try:
            data = self.session.get(url).json()
            '''
            data = {u'start_time': 1516164866, u'version': u'1.0.0-compat', \
                    u'health': u'OK', u'topics': [{u'message_count': 19019, \
                    u'paused': False, u'topic_name': u'test_topic', u'channels': [], \
                    u'depth': 19019, u'backend_depth': 9019, u'e2e_processing_latency': {u'count': 0, \
                    u'percentiles': None}}]}
            '''
            topics = data.get('topics', [])
            topics = [t for t in topics if t['topic_name'] == topic_name]

            if not topics:
                raise Exception('topic_missing_at_nsq')

            topic = topics[0]
            depth = topic['depth']
            depth += sum(c.get('depth', 0) for c in topic['channels'])
            self.log.debug('nsq_depth_check', topic=topic_name,
                            depth=depth, max_depth=self.nsq_max_depth)

            if depth < self.nsq_max_depth:
                return
            else:
                raise Exception('nsq_is_full_waiting_to_clear')
        except:
            raise
46748
async def run(self):
        
        # Implement pull max batch from queue instead of one message at a time
        while self.eh_partition_pump.pump_status != "Errored" and not self.eh_partition_pump.is_closing():
            if self.eh_partition_pump.partition_receive_handler:
                try:
                    msgs = await self.eh_partition_pump.partition_receive_handler.receive(
                        max_batch_size=self.max_batch_size,
                        timeout=self.recieve_timeout)
                except Exception as e:  # pylint: disable=broad-except
                    _logger.info("Error raised while attempting to receive messages: %r", e)
                    await self.process_error_async(e)
                else:
                    if not msgs:
                        _logger.info("No events received, queue size %r, release %r",
                                     self.eh_partition_pump.partition_receive_handler.queue_size,
                                     self.eh_partition_pump.host.eph_options.release_pump_on_timeout)
                        if self.eh_partition_pump.host.eph_options.release_pump_on_timeout:
                            await self.process_error_async(TimeoutError("No events received"))
                    else:
                        await self.process_events_async(msgs)
1017523
def create_message_buffer(size, type):
    """"""
    rtn = wrapper.nn_allocmsg(size, type)
    if rtn is None:
        raise NanoMsgAPIError()
    return rtn
643446
def receive(self):
        '''
        
        '''
        try:
            msg = self.sub.recv()
        except zmq.Again as error:
            log.error('Unable to receive messages: %s', error, exc_info=True)
            raise ListenerException(error)
        log.debug('[%s] Received %s', time.time(), msg)
        return msg, ''
536919
def next_message(self):
        
        if self._is_running:
            raise Exception('Event loop already running')
        if self._pending_messages:
            return self._pending_messages.popleft()
        self._async_session.run(self._enqueue_request_and_stop,
                                self._enqueue_notification_and_stop)
        if self._pending_messages:
            return self._pending_messages.popleft()
539201
async def serviceQueues(self, limit=None) -> int:
        

        return await self.inBoxRouter.handleAll(self.filterMsgs(self.inBox),
                                                limit)
44850
function() {
        var message = _.clone(this.attributes);
        message.restartCount = $$persistence.get('restartCount');
        message.logs = $$logging.get('logCache');
        message.events = $$logging.get('eventCache');

        $$network.transports.socketToConsole.sockets.emit('appState', message);
    }
880222
def send_to_queue(self, message):
        
        if not self.queue_delivery:
            raise RuntimeError("No queue_path provided")

        return self.queue_delivery.send(*self._message_args(message))
191352
def receive(self):
        '''
        
        '''
        while self.buffer.empty() and self.__up:
            # This sequence is skipped when the buffer is not empty.
            sleep_ms = random.randint(0, 1000)
            # log.debug('The message queue is empty, waiting %d miliseconds', sleep_ms)
            # disabled ^ as it was too noisy
            time.sleep(sleep_ms / 1000.0)
        if not self.buffer.empty():
            return self.buffer.get(block=False)
        return '', ''
1070861
def send_message(self, data, inc_session_id=False,
                     callback_function=None):
        
        self._check_registered()

        if not self.target_platform and \
           self.namespace not in self._socket_client.app_namespaces:
            if self.supporting_app_id is not None:
                self.launch()

            else:
                raise UnsupportedNamespace(
                    ("Namespace {} is not supported by running"
                     "application.").format(self.namespace))

        return self._message_func(
            self.namespace, data, inc_session_id, callback_function)
399559
function( startFunc ) {
		var self = this,
			message = self.state === munit.ASSERT_STATE_DEFAULT ? "'" + self.nsPath + "' hasn't been triggered yet" :
				self.state === munit.ASSERT_STATE_SETUP ? "'" + self.nsPath + "' is in the setup processs" :
				self.state === munit.ASSERT_STATE_ACTIVE ? "'" + self.nsPath + "' is active" :
				self.state === munit.ASSERT_STATE_TEARDOWN ? "'" + self.nsPath + "' is in the teardown processs" :
				self.state === munit.ASSERT_STATE_CLOSED ? "'" + self.nsPath + "' is closed" :
				self.state === munit.ASSERT_STATE_FINISHED ? "'" + self.nsPath + "' is finished" :
				"'" + self.nsPath + "' is in an unknown state";

		throw new munit.AssertionError( message, startFunc || self._stateError );
	}
370766
function Message(stanClient, msg, subscription) {
    this.stanClient = stanClient;
    this.msg = msg;
    this.subscription = subscription;
}
520108
function onMessage(message) {
  if (message.command === 'run') {
    run(message.opts);
    return;
  }

  if (message.command === 'stop') {
    cleanup();
  }
}
706702
def start
      message = 'Guard::Inch is running'
      message << ' in pedantic mode' if options[:pedantic]
      message << ' and inspecting private fields' if options[:private]
      ::Guard::UI.info message
      run_all if options[:all_on_start]
    end
1258563
def _wait_receive_msg(self, timeout=0.25, type=2):
        """"""
        stamp = time.monotonic()
        while (time.monotonic() - stamp) < timeout:
            try:
                message = self._mq.receive(block=False, type=2)
                return message
            except sysv_ipc.BusyError:
                time.sleep(0.001) # wait a bit then retry!
        # uh-oh timed out
        raise RuntimeError("Timed out waiting for PulseIn message")
2603
def _get_message(self, block=True, timeout=0.1, get_partition_info=None,
                     update_offset=True):
        
        start_at = time.time()
        while self.queue.empty():
            # We're out of messages, go grab some more.
            log.debug('internal queue empty, fetching more messages')
            with FetchContext(self, block, timeout):
                self._fetch()

            if not block or time.time() > (start_at + timeout):
                break

        try:
            partition, message = self.queue.get_nowait()

            if update_offset:
                # Update partition offset
                self.offsets[partition] = message.offset + 1

                # Count, check and commit messages if necessary
                self.count_since_commit += 1
                self._auto_commit()

            if get_partition_info is None:
                get_partition_info = self.partition_info
            if get_partition_info:
                return partition, message
            else:
                return message
        except queue.Empty:
            log.debug('internal queue empty after fetch - returning None')
            return None
271234
def run(self):
        """"""
        self.log("ready to receive.")
        # we use a runloop instead of synchronous recv so stopping the connection mid-recv is possible
        self.net_socket.settimeout(0.05)
        while self.keep_listening:
            try:
                packet = self.net_socket.recv(4096)
            except:
                packet = None
            if packet:
                packet, source = self._parse_msg(packet)
                if packet == "PING":
                    self.net_socket.send(b'PONG ' + source + b'\r')
                elif packet:
                    for mac_addr, recv_queue in self.inq.items():
                        # put the packet in that mac_addr recv queue
                        recv_queue.put(packet)
        self.log('is down.')