code: def _state_changed(self, previous_state, new_state):
          
          try:
              try:
                  _previous_state = constants.MessageReceiverState(previous_state)
              except ValueError:
                  _previous_state = previous_state
              try:
                  _new_state = constants.MessageReceiverState(new_state)
              except ValueError:
                  _new_state = new_state
              if _previous_state == constants.MessageReceiverState.Opening \
                      and _new_state == constants.MessageReceiverState.Error:
                  _logger.info("Receiver link failed to open - expecting to receive DETACH frame.")
              elif self._session._link_error:  # pylint: disable=protected-access
                  _logger.info("Receiver link ATTACH frame invalid - expecting to receive DETACH frame.")
              else:
                  self.on_state_changed(_previous_state, _new_state)
          except KeyboardInterrupt:
              _logger.error("Received shutdown signal while updating receiver state from {} to {}".format(
                  previous_state, new_state))
              self._error = errors.AMQPClientShutdown()
docs: Callback called whenever the underlying Receiver undergoes a change
          of state. This function wraps the states as Enums to prepare for
          calling the public callback.
  
          :param previous_state: The previous Receiver state.
          :type previous_state: int
          :param new_state: The new Receiver state.
          :type new_state: int