def get_coordinator(start_heart=True, use_cache=True):
    """
    :param start_heart: True to start heartbeating process.
    :type start_heart: ``bool``

    :param use_cache: True to use cached coordinator instance. False should only be used in tests.
    :type use_cache: ``bool``
    """
    global COORDINATOR

    if not configured():
        extra_msg = ""
        # sys._called_from_test set in conftest.py for pytest runs
        if "nose" in sys.modules.keys() or hasattr(sys, "_called_from_test"):
            extra_msg = (
                " Set ST2TESTS_REDIS_HOST and ST2TESTS_REDIS_PORT env vars to "
                "configure the coordination backend for unit and integration tests."
            )
        LOG.warning(
            "Coordination backend is not configured. Code paths which use coordination "
            "service will use best effort approach and race conditions are possible."
            f"{extra_msg}"
        )

    if not use_cache:
        return coordinator_setup(start_heart=start_heart)

    if not COORDINATOR:
        COORDINATOR = coordinator_setup(start_heart=start_heart)
        LOG.debug(
            "Initializing and caching new coordinator instance: %s" % (str(COORDINATOR))
        )
    else:
        LOG.debug("Using cached coordinator instance: %s" % (str(COORDINATOR)))

    return COORDINATOR

    :param start_heart: True to start heartbeating process.
    :type start_heart: ``bool``

    :param use_cache: True to use cached coordinator instance. False should only be used in tests.
    :type use_cache: ``bool``
    
st2common/st2common/services/coordination.py