code: def _recv_cancel(self, method_frame):
          '''Handle Basic.Cancel from broker
  
          :param MethodFrame method_frame: Basic.Cancel method frame from broker
          '''
          self.logger.warning("consumer cancelled by broker: %r", method_frame)
  
          consumer_tag = method_frame.args.read_shortstr()
  
          # NOTE: per RabbitMQ spec, no-wait is always true in Basic.Cancel from
          # broker
  
          # Remove consumer from this basic instance
          try:
              cancel_cb = self._broker_cancel_cb_map.pop(consumer_tag)
          except KeyError:
              # Must be a race condition between user's cancel and broker's cancel
              self.logger.warning(
                  '_recv_cancel: no broker-cancel-cb entry for consumer tag %r',
                  consumer_tag)
          else:
              if callable(cancel_cb):
                  # Purge from base class only when user supplies cancel_cb
                  self._purge_consumer_by_tag(consumer_tag)
  
                  # Notify user
                  cancel_cb(consumer_tagf _recv_cancel(self, method_frame):
          '''Handle Basic.Cancel from broker
  
          :param MethodFrame method_frame: Basic.Cancel method frame from broker
          '''
          self.logger.warning("consumer cancelled by broker: %r", method_frame)
  
          consumer_tag = method_frame.args.read_shortstr()
  
          # NOTE: per RabbitMQ spec, no-wait is always true in Basic.Cancel from
          # broker
  
          # Remove consumer from this basic instance
          try:
              cancel_cb = self._broker_cancel_cb_map.pop(consumer_tag)
          except KeyError:
              # Must be a race condition between user's cancel and broker's cancel
              self.logger.warning(
                  '_recv_cancel: no broker-cancel-cb entry for consumer tag %r',
                  consumer_tag)
          else:
              if callable(cancel_cb):
                  # Purge from base class only when user supplies cancel_cb
                  self._purge_consumer_by_tag(consumer_tag)
  
                  # Notify user
                  cancel_cb(consumer_tag)
docs: Handle Basic.Cancel from broker
  
          :param MethodFrame method_frame: Basic.Cancel method frame from broker