def get_database_url(settings, retries=3, retry_wait_seconds=1):
    if not settings.database_source:
        assert settings.database is not None
        return settings.database

    # Use a cached/jitter so we don't hit the script for every request.
    global _DB_URL_CACHED, _DB_URL_REFRESH_TIME, _DB_URL_REFRESH_JITTER, _DB_URL_LOCK
    with _DB_URL_LOCK:
        if _DB_URL_REFRESH_TIME > time.time() and _DB_URL_CACHED is not None:
            return _DB_URL_CACHED
        _DB_URL_REFRESH_TIME = time.time() + (insecure_random.random() * _DB_URL_REFRESH_JITTER)
        retry = 0
        while True:
            try:
                url = subprocess.check_output([settings.database_source])
                _DB_URL_CACHED = url.strip()
                return _DB_URL_CACHED
            except subprocess.CalledProcessError as e:
                logging.info("database_source: " + str(settings.database_source))
                logging.error(e)
                retry += 1
                if retry > retries:
                    raise
                time.sleep(retry_wait_seconds)
Given settings, load a database URL either from our executable source or the bare string.
dataset/ETHPy150Open dropbox/grouper/grouper/util.py/get_database_url