code: def cancel(self, queue):
          
          try:
              consumer = self._consumers[queue]
              yield consumer.channel.basic_cancel(consumer_tag=consumer.tag)
          except pika.exceptions.AMQPChannelError:
              # Consumers are tied to channels, so if this channel is dead the
              # consumer should already be canceled (and we can't get to it anyway)
              pass
          except KeyError:
              defer.returnValue(None)
  
          try:
              yield consumer.channel.close()
          except pika.exceptions.AMQPChannelError:
              pass
  
          del self._consumers[queue]
docs: Cancel the consumer for a queue.
  
          Args:
              queue (str): The name of the queue the consumer is subscribed to.
  
          Returns:
              defer.Deferred: A Deferred that fires when the consumer
                  is canceled, or None if the consumer was already canceled. Wrap
                  the call in :func:`.defer.maybeDeferred` to always receive a Deferred.