(ExceptionToCheck, tries=4, delay=3, backoff=2)
return deco_retry
Retry calling the decorated function using an exponential backoff.

    Similar to utils.decorators.retry() but customized slightly for operations tools.

    :param ExceptionToCheck: the exception to check. may be a tuple of
        excpetions to check
    :type ExceptionToCheck: Exception or tuple
    :param tries: number of times to try (not retry) before giving up
    :type tries: int
    :param delay: initial delay between retries in seconds
    :type delay: int
    :param backoff: backoff multiplier e.g. value of 2 will double the delay
        each retry
    :type backoff: int
Retry calling the decorated function using an exponential backoff.
Retry calling the decorated function using an exponential backoff .
def retry(ExceptionToCheck, tries=4, delay=3, backoff=2):
    """Retry calling the decorated function using an exponential backoff.

    Similar to utils.decorators.retry() but customized slightly for operations tools.

    :param ExceptionToCheck: the exception to check. may be a tuple of
        excpetions to check
    :type ExceptionToCheck: Exception or tuple
    :param tries: number of times to try (not retry) before giving up
    :type tries: int
    :param delay: initial delay between retries in seconds
    :type delay: int
    :param backoff: backoff multiplier e.g. value of 2 will double the delay
        each retry
    :type backoff: int"""

    def deco_retry(f):
        def f_retry(*args, **kwargs):
            mtries, mdelay = tries, delay
            while mtries > 1:
                try:
                    return f(*args, **kwargs)
                except ExceptionToCheck:
                    time.sleep(mdelay)
                    mtries -= 1
                    mdelay *= backoff
            return f(*args, **kwargs)

        return f_retry  # true decorator

    return deco_retry
def retry ( ExceptionToCheck , tries = 4 , delay = 3 , backoff = 2 ) : def deco_retry ( f ) : def f_retry ( * args , * * kwargs ) : mtries , mdelay = tries , delay while mtries > 1 : try : return f ( * args , * * kwargs ) except ExceptionToCheck : time . sleep ( mdelay ) mtries -= 1 mdelay *= backoff return f ( * args , * * kwargs ) return f_retry # true decorator return deco_retry