From efbc89c82fc554ad5e843a3d2675f1116ee2daab Mon Sep 17 00:00:00 2001 From: Krishnasis Mandal Date: Sat, 16 Mar 2024 22:44:52 +0100 Subject: [PATCH] fix: delay logic --- retry_later/lib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retry_later/lib.py b/retry_later/lib.py index f5a4b62..c327563 100644 --- a/retry_later/lib.py +++ b/retry_later/lib.py @@ -52,7 +52,7 @@ async def wrapper( if retries >= max_retries: raise e delay = retry_interval * (backoff**retries) + random.choice(range(0, max_jitter + 1)) - delay = min(max(0, max_delay), delay) + delay = delay if max_delay == -1 else min(max_delay, delay) logging.error(f"[retry later] Retrying in {delay}s due to {e}") await asyncio.sleep(delay)