Fix KazooRetry.copy to correctly copy sleep function, closes #126.
The introduction of the new `ignore_expire` argument changed the positional order of arguments. Use keyword arguments!
This commit is contained in:
@@ -4,6 +4,11 @@ Changelog
|
||||
1.4 (unreleased)
|
||||
----------------
|
||||
|
||||
Bug Handling
|
||||
************
|
||||
|
||||
- #126: Fix `KazooRetry.copy` to correctly copy sleep function.
|
||||
|
||||
Documentation
|
||||
*************
|
||||
|
||||
|
||||
@@ -88,9 +88,13 @@ class KazooRetry(object):
|
||||
|
||||
def copy(self):
|
||||
"""Return a clone of this retry manager"""
|
||||
obj = KazooRetry(self.max_tries, self.delay, self.backoff,
|
||||
self.max_jitter / 100.0, self.max_delay,
|
||||
self.sleep_func, deadline=self.deadline,
|
||||
obj = KazooRetry(max_tries=self.max_tries,
|
||||
delay=self.delay,
|
||||
backoff=self.backoff,
|
||||
max_jitter=self.max_jitter / 100.0,
|
||||
max_delay=self.max_delay,
|
||||
sleep_func=self.sleep_func,
|
||||
deadline=self.deadline,
|
||||
interrupt=self.interrupt)
|
||||
obj.retry_exceptions = self.retry_exceptions
|
||||
return obj
|
||||
|
||||
@@ -47,6 +47,12 @@ class TestRetrySleeper(unittest.TestCase):
|
||||
# gevent's sleep function is picky about the type
|
||||
eq_(type(retry._cur_delay), float)
|
||||
|
||||
def test_copy(self):
|
||||
_sleep = lambda t: None
|
||||
retry = self._makeOne(sleep_func=_sleep)
|
||||
rcopy = retry.copy()
|
||||
self.assertTrue(rcopy.sleep_func is _sleep)
|
||||
|
||||
|
||||
class TestKazooRetry(unittest.TestCase):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user