'Returns the number of messages that may be retrieved from the current
queue consumer generator via `BlockingChannel.consume` without blocking.
NEW in pika 0.10.0
:rtype: int'

def get_waiting_message_count(self):

    if (self._queue_consumer_generator is not None):
        pending_events = self._queue_consumer_generator.pending_events
        count = len(pending_events)
        if (count and (type(pending_events[(-1)]) is _ConsumerCancellationEvt)):
            count -= 1
    else:
        count = 0
    return count
