Merge "rabbit: smart timeout on missing exchange"

This commit is contained in:
Jenkins 2015-05-26 17:04:30 +00:00 committed by Gerrit Code Review
commit cf98f07f1f

View File

@ -986,18 +986,20 @@ class Connection(object):
def _publish_and_retry_on_missing_exchange(self, exchange, msg, def _publish_and_retry_on_missing_exchange(self, exchange, msg,
routing_key=None, timeout=None): 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: if not exchange.passive:
RuntimeError("_publish_and_retry_on_missing_exchange() must be " RuntimeError("_publish_and_retry_on_missing_exchange() must be "
"called with an passive exchange.") "called with an passive exchange.")
# TODO(sileht): # TODO(sileht): use @retrying
# * use timeout parameter when available # NOTE(sileht): no need to wait the application expect a response
# * use rpc_timeout if not instead of hardcoded 60 # before timeout is exshauted
# * use @retrying duration = (timeout if timeout is None
timer = rpc_common.DecayingTimer(duration=60) else self.conf.rpc_response_timeout)
timer = rpc_common.DecayingTimer(duration=duration)
timer.start() timer.start()
while True: while True: