<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def on_consumer_cancelled(self, _frame):
 """Invoked by pika when a ``Basic.Cancel`` or ``Basic.CancelOk`` is received. :param _frame: The Basic.Cancel or Basic.CancelOk frame :type _frame: pika.frame.Frame """

        self.logger.debug('Consumer has been cancelled')
        if self.is_shutting_down:
            self.channel.close()
        else:
            self.set_state(self.STATE_CONNECTED)