@decorator
def retry(call, tries, errors=Exception, timeout=0):
    if isinstance(errors, list):
        # because `except` does not catch exceptions from list
        errors = tuple(errors)

    for attempt in xrange(tries):
        try:
            return call()
        except errors:
            # Reraise error on last attempt
            if attempt + 1 == tries:
                raise
            else:
                timeout_value = timeout(attempt) if callable(timeout) else timeout
                if timeout_value > 0:
                    time.sleep(timeout_value)
dataset/ETHPy150Open Suor/funcy/funcy/flow.py/retry/original