mirror of
https://github.com/django-q2/django-q2.git
synced 2026-09-27 11:08:13 +08:00
Handle Redis errors better
This commit is contained in:
+7
-1
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user