code: def _shutdown(self):
          
          if self._channel:
              _log.info("Halting %r consumer sessions", self._channel.consumer_tags)
          self._running = False
          if self._connection and self._connection.is_open:
              self._connection.close()
          # Reset the signal handler
          for signum in (signal.SIGTERM, signal.SIGINT):
              signal.signal(signum, signal.SIG_DFL)
docs: Gracefully shut down the consumer and exit.