2
# Copyright 2014 Canonical Ltd.
5
# Edward Hope-Morley <opentastic@gmail.com>
10
from charmhelpers.core.hookenv import (
16
def retry_on_exception(num_retries, base_delay=0, exc_type=Exception):
17
"""If the decorated function raises exception exc_type, allow num_retries
18
retry attempts before raise the exception.
20
def _retry_on_exception_inner_1(f):
21
def _retry_on_exception_inner_2(*args, **kwargs):
26
return f(*args, **kwargs)
31
delay = base_delay * multiplier
33
log("Retrying '%s' %d more times (delay=%s)" %
34
(f.__name__, retries, delay), level=INFO)
39
return _retry_on_exception_inner_2
41
return _retry_on_exception_inner_1