UPDATE: there is a better maintained fork of the retrying library called tenacity, which supports more features and is in general more flexible.
Yes, there is the retrying library, which has a decorator that implements several kinds of retrying logic that you can combine:
Some examples:
@retry(stop_max_attempt_number=7)
def stop_after_7_attempts():
print "Stopping after 7 attempts"
@retry(wait_fixed=2000)
def wait_2_s():
print "Wait 2 second between retries"
@retry(wait_exponential_multiplier=1000, wait_exponential_max=10000)
def wait_exponential_1000():
print "Wait 2^x * 1000 milliseconds between each retry,"
print "up to 10 seconds, then 10 seconds afterwards"