From f3d4ba7f6b89e0f4140ffd4f1ad910553288f6f4 Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk <mehdi.abaakouk@enovance.com> Date: Thu, 7 May 2015 09:30:14 +0200 Subject: [PATCH] rabbit: smart timeout on missing exchange When we send a reply and the exchange is missing, they no need to wait more that the timeout set by the application. Change-Id: I7eb19346d72cb0a4813c964df1435d7f4c79e218 --- oslo_messaging/_drivers/impl_rabbit.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/oslo_messaging/_drivers/impl_rabbit.py b/oslo_messaging/_drivers/impl_rabbit.py index e4268648a..be19281c1 100644 --- a/oslo_messaging/_drivers/impl_rabbit.py +++ b/oslo_messaging/_drivers/impl_rabbit.py @@ -987,18 +987,20 @@ class Connection(object): def _publish_and_retry_on_missing_exchange(self, exchange, msg, routing_key=None, timeout=None): - """Publisher that retry during 60 seconds if the exchange is missing. + """Publisher that retry if the exchange is missing. """ if not exchange.passive: RuntimeError("_publish_and_retry_on_missing_exchange() must be " "called with an passive exchange.") - # TODO(sileht): - # * use timeout parameter when available - # * use rpc_timeout if not instead of hardcoded 60 - # * use @retrying - timer = rpc_common.DecayingTimer(duration=60) + # TODO(sileht): use @retrying + # NOTE(sileht): no need to wait the application expect a response + # before timeout is exshauted + duration = (timeout if timeout is None + else self.conf.rpc_response_timeout) + + timer = rpc_common.DecayingTimer(duration=duration) timer.start() while True: