Handle Redis errors better

This commit is contained in:
Ilan Steemers
2015-07-07 17:47:49 +02:00
parent 33b7fe50ed
commit b801c480f5
2 changed files with 11 additions and 2 deletions
+7 -1
View File
@@ -294,7 +294,13 @@ def pusher(task_queue, e, list_key=Conf.Q_LIST, r=redis_client):
"""
logger.info(_('{} pushing tasks at {}').format(current_process().name, current_process().pid))
while True:
task = r.blpop(list_key, 1)
try:
task = r.blpop(list_key, 1)
except Exception as e:
logger.error(e)
# redis probably crashed. Let the sentinel handle it.
sleep(10)
break
if task:
task = task[1]
task_queue.put(task)
+4 -1
View File
@@ -147,7 +147,10 @@ class Stat(Status):
return '{}:{}'.format(Conf.Q_STAT, cluster_id)
def save(self):
self.r.set(self.key, SignedPackage.dumps(self, True), 3)
try:
self.r.set(self.key, SignedPackage.dumps(self, True), 3)
except Exception as e:
logger.error(e)
def empty_queues(self):
return self.done_q_size + self.task_q_size == 0