Skip to content

Instantly share code, notes, and snippets.

View arunshankerprasad's full-sized avatar

Arun Shanker Prasad arunshankerprasad

View GitHub Profile
@arunshankerprasad
arunshankerprasad / retry_decorator.py
Last active December 28, 2015 07:49
Decorator for retrying a function if an exception occurs
import time
class retry(object):
defaultexceptions = (Exception,)
def __init__(self, tries=1, exceptions=None, delay=0):
"""
Decorator for retrying a function if an exception occurs
@source: http://peter-hoffmann.com/2010/retry-decorator-python.html (updated to dynamically override tries)
Usage: