def execute_with_retry()

in integ/validate_cloudwatch/validator.py [0:0]


def execute_with_retry(max_retry_attempts, retriable_function, *argv):
    retry_time_secs = 10
    attempt = 0

    while attempt < max_retry_attempts:
        success, ret_message = retriable_function(*argv)
        # If we succeed, then return the success response.
        if success:
            return True

        # If we fail, then increment the attempt and sleep for the specified time.
        print(ret_message +
              '. Current retry attempt: ' + str(attempt) +
              '. Max retry attempt: ' + str(max_retry_attempts))
        attempt += 1
        time.sleep(retry_time_secs)

    sys.exit(retriable_function.__name__ + ' failed after exhaustion of retry limit.')