diff --git a/oslo/messaging/_drivers/amqpdriver.py b/oslo/messaging/_drivers/amqpdriver.py index 41dbb66a6..0bebe8a79 100644 --- a/oslo/messaging/_drivers/amqpdriver.py +++ b/oslo/messaging/_drivers/amqpdriver.py @@ -25,6 +25,7 @@ from oslo import messaging from oslo.messaging._drivers import amqp as rpc_amqp from oslo.messaging._drivers import base from oslo.messaging._drivers import common as rpc_common +from oslo.messaging._i18n import _ from oslo.messaging._i18n import _LI LOG = logging.getLogger(__name__) @@ -207,7 +208,7 @@ class ReplyWaiter(object): @staticmethod def _raise_timeout_exception(msg_id): raise messaging.MessagingTimeout( - 'Timed out waiting for a reply to message ID %s' % msg_id) + _('Timed out waiting for a reply to message ID %s.') % msg_id) def _process_reply(self, data): result = None @@ -271,7 +272,8 @@ class ReplyWaiter(object): # have the first thread take responsibility for passing replies not # intended for itself to the appropriate thread. # - timer = rpc_common.DecayingTimer(duration=timeout).start() + timer = rpc_common.DecayingTimer(duration=timeout) + timer.start() final_reply = None while True: if self.conn_lock.acquire(False): diff --git a/oslo/messaging/_drivers/common.py b/oslo/messaging/_drivers/common.py index 9a4f69617..3d671438c 100644 --- a/oslo/messaging/_drivers/common.py +++ b/oslo/messaging/_drivers/common.py @@ -340,15 +340,14 @@ class DecayingTimer(object): def start(self): if self._duration is not None: self._ends_at = time.time() + max(0, self._duration) - return self def check_return(self, timeout_callback, *args, **kwargs): maximum = kwargs.pop('maximum', None) if self._duration is None: return None if maximum is None else maximum if self._ends_at is None: - raise RuntimeError("Can not check/return a timeout from a timer" - " that has not been started") + raise RuntimeError(_("Can not check/return a timeout from a timer" + " that has not been started.")) left = self._ends_at - time.time() if left <= 0: diff --git a/oslo/messaging/_drivers/impl_qpid.py b/oslo/messaging/_drivers/impl_qpid.py index 8c9b86d8c..de477f4d4 100644 --- a/oslo/messaging/_drivers/impl_qpid.py +++ b/oslo/messaging/_drivers/impl_qpid.py @@ -642,7 +642,8 @@ class Connection(object): def iterconsume(self, limit=None, timeout=None): """Return an iterator that will consume from all queues/consumers.""" - timer = rpc_common.DecayingTimer(duration=timeout).start() + timer = rpc_common.DecayingTimer(duration=timeout) + timer.start() def _raise_timeout(exc): LOG.debug('Timed out waiting for RPC response: %s', exc) diff --git a/oslo/messaging/_drivers/impl_rabbit.py b/oslo/messaging/_drivers/impl_rabbit.py index 732d183f6..a93ad7bf0 100644 --- a/oslo/messaging/_drivers/impl_rabbit.py +++ b/oslo/messaging/_drivers/impl_rabbit.py @@ -701,7 +701,8 @@ class Connection(object): def iterconsume(self, limit=None, timeout=None): """Return an iterator that will consume from all queues/consumers.""" - timer = rpc_common.DecayingTimer(duration=timeout).start() + timer = rpc_common.DecayingTimer(duration=timeout) + timer.start() def _raise_timeout(exc): LOG.debug('Timed out waiting for RPC response: %s', exc)