work around redis connection failures in the callback receiver

if redis stops/starts, sometimes the callback receiver doesn't recover
without a restart; this fixes that
This commit is contained in:
Ryan Petrello 2020-04-09 15:38:03 -04:00
parent 907da2ae61
commit 80147acc1c
No known key found for this signature in database
GPG Key ID: F2AA5F2122351777

View File

@ -118,9 +118,14 @@ class AWXConsumerRedis(AWXConsumerBase):
queue = redis.Redis.from_url(settings.BROKER_URL)
while True:
res = queue.blpop(self.queues)
res = json.loads(res[1])
self.process_task(res)
try:
res = queue.blpop(self.queues)
res = json.loads(res[1])
self.process_task(res)
except redis.exceptions.RedisError:
logger.exception(f"encountered an error communicating with redis")
except (json.JSONDecodeError, KeyError):
logger.exception(f"failed to decode JSON message from redis")
if self.should_stop:
return