summaryrefslogtreecommitdiff
path: root/decorator_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-07-12 20:52:49 -0700
committerScott Gasch <[email protected]>2021-07-12 20:52:49 -0700
commit97fbe845e5dfdbda22521117c1783e1fd8515952 (patch)
tree8b0ac61be1d670621abc994beef84e249f0ad95a /decorator_utils.py
parenta838c154135b2420d9047a101caf24a2c9f593c2 (diff)
Random changes.
Diffstat (limited to 'decorator_utils.py')
-rw-r--r--decorator_utils.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/decorator_utils.py b/decorator_utils.py
index 2817239..0d5b3e3 100644
--- a/decorator_utils.py
+++ b/decorator_utils.py
@@ -192,7 +192,7 @@ def retry_predicate(
tries: int,
*,
predicate: Callable[..., bool],
- delay_sec: float = 3,
+ delay_sec: float = 3.0,
backoff: float = 2.0,
):
"""Retries a function or method up to a certain number of times
@@ -202,10 +202,10 @@ def retry_predicate(
delay_sec sets the initial delay period in seconds.
backoff is a multiplied (must be >1) used to modify the delay.
predicate is a function that will be passed the retval of the
- decorated function and must return True to stop or False to
- retry.
+ decorated function and must return True to stop or False to
+ retry.
"""
- if backoff < 1:
+ if backoff < 1.0:
msg = f"backoff must be greater than or equal to 1, got {backoff}"
logger.critical(msg)
raise ValueError(msg)
@@ -225,9 +225,11 @@ def retry_predicate(
@functools.wraps(f)
def f_retry(*args, **kwargs):
mtries, mdelay = tries, delay_sec # make mutable
+ logger.debug(f'deco_retry: will make up to {mtries} attempts...')
retval = f(*args, **kwargs)
while mtries > 0:
if predicate(retval) is True:
+ logger.debug('Predicate succeeded, deco_retry is done.')
return retval
logger.debug("Predicate failed, sleeping and retrying.")
mtries -= 1