Skip to content

Instantly share code, notes, and snippets.

@ssbb
Created March 6, 2015 19:46
Show Gist options
  • Save ssbb/810c9052d4fde6c78e1f to your computer and use it in GitHub Desktop.
Save ssbb/810c9052d4fde6c78e1f to your computer and use it in GitHub Desktop.
import decorator
def retry(times, *exception_types):
@decorator.decorator
def try_it(func, *fargs, **fkwargs):
for i in xrange(times):
try:
return func(*fargs, **fkwargs)
except exception_types or Exception:
pass
return try_it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment