Browse Source

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
changes/32/144132/4
Jie Li 7 years ago
parent
commit
3e2d142a87
4 changed files with 10 additions and 7 deletions
  1. +4
    -2
      oslo/messaging/_drivers/amqpdriver.py
  2. +2
    -3
      oslo/messaging/_drivers/common.py
  3. +2
    -1
      oslo/messaging/_drivers/impl_qpid.py
  4. +2
    -1
      oslo/messaging/_drivers/impl_rabbit.py

+ 4
- 2
oslo/messaging/_drivers/amqpdriver.py View File

@ -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):


+ 2
- 3
oslo/messaging/_drivers/common.py View File

@ -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()


+ 2
- 1
oslo/messaging/_drivers/impl_qpid.py View File

@ -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)


+ 2
- 1
oslo/messaging/_drivers/impl_rabbit.py View File

@ -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)


Loading…
Cancel
Save