From 3e2d142a871783ab2568a07efbdacbd476524fac Mon Sep 17 00:00:00 2001 From: Jie Li Date: Fri, 26 Dec 2014 20:22:21 +0800 Subject: [PATCH] Fix some comments in a backporting review session * add i18n support to some exception messages * remove the return value of DecayingTimer.start() Relates to review: I898a236a384b3466147026abc7a1ee21801e8ca1 Change-Id: I7adf5478732f1f46db1009b059b66ff8af6ecdc3 --- oslo/messaging/_drivers/amqpdriver.py | 6 ++++-- oslo/messaging/_drivers/common.py | 5 ++--- oslo/messaging/_drivers/impl_qpid.py | 3 ++- oslo/messaging/_drivers/impl_rabbit.py | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/oslo/messaging/_drivers/amqpdriver.py b/oslo/messaging/_drivers/amqpdriver.py index 6e1451807..20f51f69f 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__) @@ -204,7 +205,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 @@ -268,7 +269,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 fa21a437d..6696693e1 100644 --- a/oslo/messaging/_drivers/common.py +++ b/oslo/messaging/_drivers/common.py @@ -346,14 +346,13 @@ 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): if self._duration is None: return None 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.")) maximum = kwargs.pop('maximum', None) left = self._ends_at - time.time() 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 4d9d7c893..aae880686 100644 --- a/oslo/messaging/_drivers/impl_rabbit.py +++ b/oslo/messaging/_drivers/impl_rabbit.py @@ -695,7 +695,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)