'Cancel the queue consumer created by `BlockingChannel.consume`,
rejecting all pending ackable messages.
NOTE: If you\'re looking to cancel a consumer issued with
BlockingChannel.basic_consume then you should call
BlockingChannel.basic_cancel.
:return int: The number of messages requeued by Basic.Nack.
NEW in 0.10.0: returns 0'

def cancel(self):

    if (self._queue_consumer_generator is None):
        LOGGER.warning('cancel:    queue    consumer    generator    is    inactive    (already    cancelled    by    client    or    broker?)')
        return 0
    try:
        (_, no_ack, _) = self._queue_consumer_generator.params
        if (not no_ack):
            pending_events = self._queue_consumer_generator.pending_events
            for _ in compat.xrange(self.get_waiting_message_count()):
                evt = pending_events.popleft()
                self._impl.basic_reject(evt.method.delivery_tag, requeue=True)
        self.basic_cancel(self._queue_consumer_generator.consumer_tag)
    finally:
        self._queue_consumer_generator = None
    return 0
