code: def close(self):
          
          # The main thread may keep connections open for a long time
          # w/o publishing heartbeats, which means that they'll end up
          # being closed by the time the broker is closed.  When that
          # happens, pika logs a bunch of scary stuff so we want to
          # filter that out.
          logging_filter = _IgnoreScaryLogs()
          logging.getLogger("pika.adapters.base_connection").addFilter(logging_filter)
          logging.getLogger("pika.adapters.blocking_connection").addFilter(logging_filter)
  
          self.logger.debug("Closing channels and connections...")
          for channel_or_conn in chain(self.channels, self.connections):
              try:
                  channel_or_conn.close()
              except pika.exceptions.AMQPError:
                  pass
  
              except Exception:  # pragma: no cover
                  self.logger.debug("Encountered an error while closing %r.", channel_or_conn, exc_info=True)
          self.logger.debug("Channels and connections closed.")
docs: Close all open RabbitMQ connections.