Skip to content

Instantly share code, notes, and snippets.

@matin
Created September 8, 2010 17:45

Revisions

  1. matin revised this gist Sep 25, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ def retry(tries):
    def decorator(function):
    def decorated_function(*args, **kwargs):
    tried = 0
    while tried < tries:
    while tried <= tries:
    try:
    return function(*args, **kwargs)
    except Exception, exc:
  2. matin created this gist Sep 8, 2010.
    12 changes: 12 additions & 0 deletions gistfile1.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    def retry(tries):
    def decorator(function):
    def decorated_function(*args, **kwargs):
    tried = 0
    while tried < tries:
    try:
    return function(*args, **kwargs)
    except Exception, exc:
    tried += 1
    raise exc
    return decorated_function
    return decorator