Mercurial > hg > config
view python/example/retry.py @ 778:9b75dc884c78
add check_endpoints script
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 13 Jul 2016 16:09:11 -0700 |
parents | 88f19ebb43ea |
children |
line wrap: on
line source
def retry(f, retries=5, args=(), kw=None, exceptions=()): kw = kw or {} for index in range(retries): try: return f(*args, **kw) except Exception as e: if isinstance(e, exceptions): print ("something bad happen") else: raise raise RetryTimeout("Tries a bunch of times :(")