def retry(ExceptionToCheck, tries=MAX_ATTEMPTS, delay=SECONDS_BETWEEN_ATTEMPTS,<EOL>backoff=BACKOFF_MULTIPLIER):
def deco_retry(f):<EOL><INDENT>@wraps(f)<EOL>def f_retry(*args, **kwargs):<EOL><INDENT>mtries, mdelay = tries, delay<EOL>while mtries > <NUM_LIT:1>:<EOL><INDENT>try:<EOL><INDENT>return f(*args, **kwargs)<EOL><DEDENT>except ExceptionToCheck as e:<EOL><INDENT>LOG.debug("<STR_LIT>",<EOL>{'<STR_LIT>': str(e), '<STR_LIT>': mdelay})<EOL>time.sleep(mdelay)<EOL>mtries -= <NUM_LIT:1><EOL>mdelay *= backoff<EOL><DEDENT><DEDENT>return f(*args, **kwargs)<EOL><DEDENT>return f_retry  <EOL><DEDENT>return deco_retry<EOL>
Retry calling the decorated function using an exponential backoff.
    Reference: http://www.saltycrane.com/blog/2009/11/trying-out-retry
    -decorator-python/

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