MCPcopy
hub / github.com/pika/pika / close

Method close

pika/channel.py:576–616  ·  view source on GitHub ↗

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

(self,
              reply_code: int = 0,
              reply_text: str = "Normal shutdown")

Source from the content-addressed store, hash-verified

574 [spec.Basic.RecoverOk])
575
576 def close(self,
577 reply_code: int = 0,
578 reply_text: str = "Normal shutdown") -> None:
579 """Invoke a graceful shutdown of the channel with the AMQP Broker.
580
581 If channel is OPENING, transition to CLOSING and suppress the incoming
582 Channel.OpenOk, if any.
583
584 :param int reply_code: The reason code to send to broker
585 :param str reply_text: The reason text to send to broker
586
587 :raises ChannelWrongStateError: if channel is closed or closing
588
589 """
590 if self.is_closed or self.is_closing:
591 # Whoever is calling `close` might expect the on-channel-close-cb
592 # to be called, which won't happen when it's already closed.
593 self._raise_if_not_open()
594
595 # If channel is OPENING, we will transition it to CLOSING state,
596 # causing the _on_openok method to suppress the OPEN state transition
597 # and the on-channel-open-callback
598
599 LOGGER.info('Closing channel (%s): %r on %s', reply_code, reply_text,
600 self)
601
602 # Save the reason info so that we may use it in the '_on_channel_close'
603 # callback processing
604 self._closing_reason = exceptions.ChannelClosedByClient(
605 reply_code, reply_text)
606
607 for consumer_tag in list(self._consumers.keys()):
608 if consumer_tag not in self._cancelled:
609 self.basic_cancel(consumer_tag=consumer_tag)
610
611 # Change state after cancelling consumers to avoid
612 # ChannelWrongStateError exception from basic_cancel
613 self._set_state(self.CLOSING)
614
615 self._rpc(spec.Channel.Close(reply_code, reply_text, 0, 0),
616 self._on_closeok, [spec.Channel.CloseOk])
617
618 def confirm_delivery(
619 self,

Calls 4

_raise_if_not_openMethod · 0.95
basic_cancelMethod · 0.95
_set_stateMethod · 0.95
_rpcMethod · 0.95