Use StopWatch timer when waiting for message
When waiting for a message in a queue, the queue.get(block=True) prevent the heartbeats to be sent at correct interval. So instead of blocking the thread, doing a loop using a StopWatch timer until the timeout is reached. Closes-Bug: #2035113 Signed-off-by: Arnaud Morin <arnaud.morin@ovhcloud.com> Change-Id: Ie5cf5d2bd281508bcd2db1409f18ad96b0822639
This commit is contained in:
parent
b5244bd05a
commit
b62208a54c
|
@ -496,12 +496,18 @@ class ReplyWaiters(object):
|
||||||
self._wrn_threshold = 10
|
self._wrn_threshold = 10
|
||||||
|
|
||||||
def get(self, msg_id, timeout):
|
def get(self, msg_id, timeout):
|
||||||
try:
|
watch = timeutils.StopWatch(duration=timeout)
|
||||||
return self._queues[msg_id].get(block=True, timeout=timeout)
|
watch.start()
|
||||||
except queue.Empty:
|
while not watch.expired():
|
||||||
raise oslo_messaging.MessagingTimeout(
|
try:
|
||||||
'Timed out waiting for a reply '
|
# NOTE(amorin) we can't use block=True
|
||||||
'to message ID %s' % msg_id)
|
# See lp-2035113
|
||||||
|
return self._queues[msg_id].get(block=False)
|
||||||
|
except queue.Empty:
|
||||||
|
time.sleep(0.5)
|
||||||
|
raise oslo_messaging.MessagingTimeout(
|
||||||
|
'Timed out waiting for a reply '
|
||||||
|
'to message ID %s' % msg_id)
|
||||||
|
|
||||||
def put(self, msg_id, message_data):
|
def put(self, msg_id, message_data):
|
||||||
LOG.info('Received RPC response for msg %s', msg_id)
|
LOG.info('Received RPC response for msg %s', msg_id)
|
||||||
|
|
Loading…
Reference in New Issue