Skip to content

Commit 4242da8

Browse files
ceacheStephenSorriaux
authored andcommitted
fix(core): support deprecated KazooRetry argument (#545)
Accept kazoo<=2.5.0 KazooRetry 'max_jitter' argument and display a warning for backward compatibility.
1 parent 37bcda3 commit 4242da8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

kazoo/retry.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import logging
22
import random
33
import time
4+
import warnings
45

56
from kazoo.exceptions import (
67
ConnectionClosedError,
@@ -42,7 +43,7 @@ class KazooRetry(object):
4243
SessionExpiredError,
4344
)
4445

45-
def __init__(self, max_tries=1, delay=0.1, backoff=2,
46+
def __init__(self, max_tries=1, delay=0.1, backoff=2, max_jitter=None,
4647
max_delay=60, ignore_expire=True, sleep_func=time.sleep,
4748
deadline=None, interrupt=None):
4849
"""Create a :class:`KazooRetry` instance for retrying function
@@ -53,6 +54,8 @@ def __init__(self, max_tries=1, delay=0.1, backoff=2,
5354
:param delay: Initial delay between retry attempts.
5455
:param backoff: Backoff multiplier between retry attempts.
5556
Defaults to 2 for exponential backoff.
57+
:param max_jitter: *Deprecated* Jitter is now uniformly distributed
58+
across retries.
5659
:param max_delay: Maximum delay in seconds, regardless of other
5760
backoff settings. Defaults to one minute.
5861
:param ignore_expire:
@@ -65,6 +68,12 @@ def __init__(self, max_tries=1, delay=0.1, backoff=2,
6568
between retries.
6669
6770
"""
71+
if max_jitter is not None:
72+
warnings.warn(
73+
'Passing max_jitter to retry configuration is deprecated.'
74+
' Retry jitter is now automacallity uniform across retries.'
75+
' The parameter will be ignored.',
76+
DeprecationWarning, stacklevel=2)
6877
self.max_tries = max_tries
6978
self.delay = delay
7079
self.backoff = backoff

0 commit comments

Comments
 (0)