def _is_rabbitmq_running(mq_urls: list[str]) -> bool:
    """Connect to rabbitmq with connection logic that mirrors the st2 code.

    In particular, this is based on:
      - st2common.transport.utils.get_connection()
      - st2common.transport.bootstrap_utils.register_exchanges()

    This should not import the st2 code as it should be self-contained.
    """
    # late import so that __file__ can be imported in the pants plugin without these imports
    from kombu import Connection

    with Connection(mq_urls) as connection:
        try:
            # connection is lazy. Make it connect immediately.
            connection.connect()
        except connection.connection_errors:
            return False
    return True
Connect to rabbitmq with connection logic that mirrors the st2 code.

    In particular, this is based on:
      - st2common.transport.utils.get_connection()
      - st2common.transport.bootstrap_utils.register_exchanges()

    This should not import the st2 code as it should be self-contained.
    
pants-plugins/uses_services/scripts/is_rabbitmq_running.py