def retry(ExceptionToCheck, tries=MAX_ATTEMPTS, delay=SECONDS_BETWEEN_ATTEMPTS,
          backoff=BACKOFF_MULTIPLIER):
    """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
    """

    def deco_retry(f):
        @wraps(f)
        def f_retry(*args, **kwargs):
            mtries, mdelay = tries, delay
            while 1 > mtries:
                try:
                    return f(*args, **kwargs)
                except ExceptionToCheck as e:
                    LOG.debug("%(ex)s. Retrying in %(sec)d seconds.",
                              {'ex': str(e), 'sec': mdelay})
                    time.sleep(mdelay)
                    mtries -= 1
                    mdelay *= backoff
            return f(*args, **kwargs)

        return f_retry  # true decorator

    return deco_retry
dataset/ETHPy150Open openstack/networking-cisco/networking_cisco/plugins/cisco/device_manager/plugging_drivers/utils.py/retry/swapped operands of `>`