mirror of
https://github.com/ansible/awx.git
synced 2026-03-06 03:01:06 -03:30
actually do exponential calc rather than *2
* Log the time til reconnect attemp to log message rather than attempt number
This commit is contained in:
@@ -117,19 +117,19 @@ class AWXConsumerRedis(AWXConsumerBase):
|
|||||||
super(AWXConsumerRedis, self).run(*args, **kwargs)
|
super(AWXConsumerRedis, self).run(*args, **kwargs)
|
||||||
self.worker.on_start()
|
self.worker.on_start()
|
||||||
|
|
||||||
retry = 0
|
time_to_sleep = 1
|
||||||
while True:
|
while True:
|
||||||
queue = redis.Redis.from_url(settings.BROKER_URL)
|
queue = redis.Redis.from_url(settings.BROKER_URL)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
res = queue.blpop(self.queues)
|
res = queue.blpop(self.queues)
|
||||||
retry = 0
|
time_to_sleep = 1
|
||||||
res = json.loads(res[1])
|
res = json.loads(res[1])
|
||||||
self.process_task(res)
|
self.process_task(res)
|
||||||
except redis.exceptions.RedisError:
|
except redis.exceptions.RedisError:
|
||||||
logger.exception(f"encountered an error communicating with redis. Reconnect attempt {retry}")
|
time_to_sleep = min(time_to_sleep*2, 30)
|
||||||
retry += 1
|
logger.exception(f"encountered an error communicating with redis. Reconnect attempt in {time_to_sleep} seconds")
|
||||||
time.sleep(min(retry * 2, 30))
|
time.sleep(time_to_sleep)
|
||||||
except (json.JSONDecodeError, KeyError):
|
except (json.JSONDecodeError, KeyError):
|
||||||
logger.exception("failed to decode JSON message from redis")
|
logger.exception("failed to decode JSON message from redis")
|
||||||
if self.should_stop:
|
if self.should_stop:
|
||||||
|
|||||||
Reference in New Issue
Block a user