From 8e36ba8d24c198cb5e6c0e4ddc29a08904e3e10c Mon Sep 17 00:00:00 2001 From: Samer Deeb Date: Wed, 1 Oct 2014 09:55:21 +0300 Subject: [PATCH] Fix sleep function call Remove time.sleep method reference in class and use time.sleep directly. Change-Id: Ib4c02061b29c0d584d603746a78ab50922f781c3 Closes-Bug: 1375698 --- neutron/plugins/mlnx/common/comm_utils.py | 3 +-- neutron/tests/unit/mlnx/test_mlnx_comm_utils.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/neutron/plugins/mlnx/common/comm_utils.py b/neutron/plugins/mlnx/common/comm_utils.py index 834b5a2cb..f426908f2 100644 --- a/neutron/plugins/mlnx/common/comm_utils.py +++ b/neutron/plugins/mlnx/common/comm_utils.py @@ -35,7 +35,6 @@ class RetryDecorator(object): :param retries: number of times to try before giving up :raises: exceptionToCheck """ - sleep_fn = time.sleep def __init__(self, exceptionToCheck, interval=cfg.CONF.ESWITCH.request_timeout / 1000, @@ -56,7 +55,7 @@ class RetryDecorator(object): except self.exc: LOG.debug(_("Request timeout - call again after " "%s seconds"), sleep_interval) - RetryDecorator.sleep_fn(sleep_interval) + time.sleep(sleep_interval) num_of_iter -= 1 sleep_interval *= self.backoff_rate diff --git a/neutron/tests/unit/mlnx/test_mlnx_comm_utils.py b/neutron/tests/unit/mlnx/test_mlnx_comm_utils.py index bb8bdcced..49f2eacee 100644 --- a/neutron/tests/unit/mlnx/test_mlnx_comm_utils.py +++ b/neutron/tests/unit/mlnx/test_mlnx_comm_utils.py @@ -29,8 +29,7 @@ class WrongException(Exception): class TestRetryDecorator(base.BaseTestCase): def setUp(self): super(TestRetryDecorator, self).setUp() - self.sleep_fn_p = mock.patch.object(comm_utils.RetryDecorator, - 'sleep_fn') + self.sleep_fn_p = mock.patch("time.sleep") self.sleep_fn = self.sleep_fn_p.start() def test_no_retry_required(self): -- 2.45.2