def send_ready(self, conn, count):
        if self.state == CLOSED:
            self.logger.debug('[%s] cannot send RDY (in state CLOSED)' % conn)
            return

        if self.state == BACKOFF:
            self.logger.debug('[%s] cannot send RDY (in state BACKOFF)' % conn)
            return

        if self.state == THROTTLED and self.total_in_flight_or_ready:
            msg = '[%s] cannot send RDY (THROTTLED and %d in flight or ready)'
            self.logger.debug(msg % (conn, self.total_in_flight_or_ready))
            return

        if not conn.is_connected:
            self.logger.debug('[%s] cannot send RDY (connection closed)' % conn)
            return

        total = self.total_ready_count - conn.ready_count + count
        if total > self.max_in_flight:
            if not (conn.ready_count or conn.in_flight):
                self.logger.debug('[%s] sending later' % conn)
                gevent.spawn_later(5, self.send_ready, conn, count)
            return

        self.logger.debug('[%s] sending RDY %d' % (conn, count))

        try:
            conn.ready(count)
        except NSQSocketError as error:
            self.logger.warn('[%s] RDY %d failed (%r)' % (conn, count, error))
dataset/ETHPy150Open wtolson/gnsq/gnsq/reader.py/Reader.send_ready/original