import time


def is_task_successful(task, retry=10 , interval=5):
    """
    Method to check the task state.
    :param task: VMware task.
    :param retry(int): Number of Retries.
    :param interval(int): Interval between each retry.
    :return: bool(
    """
    while retry > 0:
        task_status = str(task.info.state)
        if task_status == 'success':
            return True
        if task_status== 'running':
            time.sleep(interval)
        retry -= 1
    print("Task not successful.")
    return False