Fix sleep function call
Remove time.sleep method reference in class and use time.sleep directly. Change-Id: Ib4c02061b29c0d584d603746a78ab50922f781c3 Closes-Bug: 1375698
This commit is contained in:
parent
bb37895c2f
commit
e66b6150cb
@ -35,7 +35,6 @@ class RetryDecorator(object):
|
|||||||
:param retries: number of times to try before giving up
|
:param retries: number of times to try before giving up
|
||||||
:raises: exceptionToCheck
|
:raises: exceptionToCheck
|
||||||
"""
|
"""
|
||||||
sleep_fn = time.sleep
|
|
||||||
|
|
||||||
def __init__(self, exceptionToCheck,
|
def __init__(self, exceptionToCheck,
|
||||||
interval=cfg.CONF.ESWITCH.request_timeout / 1000,
|
interval=cfg.CONF.ESWITCH.request_timeout / 1000,
|
||||||
@ -56,7 +55,7 @@ class RetryDecorator(object):
|
|||||||
except self.exc:
|
except self.exc:
|
||||||
LOG.debug(_("Request timeout - call again after "
|
LOG.debug(_("Request timeout - call again after "
|
||||||
"%s seconds"), sleep_interval)
|
"%s seconds"), sleep_interval)
|
||||||
RetryDecorator.sleep_fn(sleep_interval)
|
time.sleep(sleep_interval)
|
||||||
num_of_iter -= 1
|
num_of_iter -= 1
|
||||||
sleep_interval *= self.backoff_rate
|
sleep_interval *= self.backoff_rate
|
||||||
|
|
||||||
|
@ -29,8 +29,7 @@ class WrongException(Exception):
|
|||||||
class TestRetryDecorator(base.BaseTestCase):
|
class TestRetryDecorator(base.BaseTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestRetryDecorator, self).setUp()
|
super(TestRetryDecorator, self).setUp()
|
||||||
self.sleep_fn_p = mock.patch.object(comm_utils.RetryDecorator,
|
self.sleep_fn_p = mock.patch("time.sleep")
|
||||||
'sleep_fn')
|
|
||||||
self.sleep_fn = self.sleep_fn_p.start()
|
self.sleep_fn = self.sleep_fn_p.start()
|
||||||
|
|
||||||
def test_no_retry_required(self):
|
def test_no_retry_required(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user