def close(self, reply_code=0, reply_text="Normal Shutdown"):
        """Invoke a graceful shutdown of the channel with the AMQP Broker.

        If channel is OPENING, transition to CLOSING and suppress the incoming
        Channel.OpenOk, if any.

        :param int reply_code: The reason code to send to broker
        :param str reply_text: The reason text to send to broker

        :raises ChannelClosed: if channel is already closed
        :raises ChannelAlreadyClosing: if channel is already closing
        """
        if self.is_closed:
            # Whoever is calling `close` might expect the on-channel-close-cb
            # to be called, which won't happen when it's already closed
            raise exceptions.ChannelClosed('Already closed: %s' % self)

        if self.is_closing:
            # Whoever is calling `close` might expect their reply_code and
            # reply_text to be sent to broker, which won't happen if we're
            # already closing.
            raise exceptions.ChannelAlreadyClosing('Already closing: %s' % self)

        # If channel is OPENING, we will transition it to CLOSING state,
        # causing the _on_openok method to suppress the OPEN state transition
        # and the on-channel-open-callback

        LOGGER.info('Closing channel (%s): %r on %s',
                    reply_code, reply_text, self)

        for consumer_tag in dictkeys(self._consumers):
            if consumer_tag not in self._cancelled:
                self.basic_cancel(consumer_tag=consumer_tag)

        # Change state after cancelling consumers to avoid ChannelClosed
        # exception from basic_cancel
        self._set_state(self.CLOSING)

        self._rpc(spec.Channel.Close(reply_code, reply_text, 0, 0),
                  self._on_closeok, [spec.Channel.CloseOk])
dataset/ETHPy150Open pika/pika/pika/channel.py/Channel.close/original