@contextlib.contextmanager
def RetryTask(task, attempts, init_delay, max_delay, backoff, warn_idx, error_types):
    try:
        yield
    except error_types as exc_value:
        try_count = task.request.retries
        if warn_idx is not None and try_count >= warn_idx:
            capture_retry_message(task)
        countdown = get_countdown(try_count, init_delay, max_delay, backoff)
        task.max_retries = attempts
        raise task.retry(exc=exc_value, countdown=countdown)
dataset/ETHPy150Open CenterForOpenScience/waterbutler/waterbutler/providers/osfstorage/tasks/utils.py/RetryTask/original