def check_redis_deployment(redis_env_folder, port):
    """
    Verifies that a Redis instance has been deployed properly by doing a PING against the server.
    If the instance hasn't been started already then this method will start it itself and will
    close it once the verification is done.

    @param redis_env_folder: Folder where the Redis config files are stored.
    @param port: Port under which the redis instance deployment to verify is running or is supposed to run.

    @return True if the check passes. Otherwise an exception is thrown.
    """

    started_by_us = False

    # Find out whether it's running.
    try:
        r = redis.StrictRedis(host="127.0.0.1", port=port, db=0)
        r.ping()
    except ConnectionError:
        # The server seems to be down, we start it.
        result = start_redis.delay(redis_env_folder, "redis_%d.conf" % port)
        while not result.ready():
            time.sleep(0.1)
        started_by_us = True

    r = redis.StrictRedis(host="127.0.0.1", port=port, db=0)
    r.ping()

    if started_by_us:
        # r.shutdown()
        pass

    return True
dataset/ETHPy150Open weblabdeusto/weblabdeusto/tools/wcloud/wcloud/actions/redis_actions.py/check_redis_deployment/original