mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
make task resumable (#2132)
### What problem does this PR solve? ### Type of change - [x] Performance Improvement
This commit is contained in:
@ -107,7 +107,7 @@ class RedisDB:
|
||||
payload = {"message": json.dumps(message)}
|
||||
pipeline = self.REDIS.pipeline()
|
||||
pipeline.xadd(queue, payload)
|
||||
pipeline.expire(queue, exp)
|
||||
#pipeline.expire(queue, exp)
|
||||
pipeline.execute()
|
||||
return True
|
||||
except Exception as e:
|
||||
@ -143,8 +143,22 @@ class RedisDB:
|
||||
if 'key' in str(e):
|
||||
pass
|
||||
else:
|
||||
logging.warning("[EXCEPTION]consumer" + str(queue_name) + "||" + str(e))
|
||||
logging.warning("[EXCEPTION]consumer: " + str(queue_name) + "||" + str(e))
|
||||
return None
|
||||
|
||||
def get_unacked_for(self, consumer_name, queue_name, group_name):
|
||||
try:
|
||||
group_info = self.REDIS.xinfo_groups(queue_name)
|
||||
if not any(e["name"] == group_name for e in group_info):
|
||||
return
|
||||
pendings = self.REDIS.xpending_range(queue_name, group_name, min=0, max=10000000000000, count=1, consumername=consumer_name)
|
||||
if not pendings: return
|
||||
msg_id = pendings[0]["message_id"]
|
||||
msg = self.REDIS.xrange(queue_name, min=msg_id, count=1)
|
||||
_, payload = msg[0]
|
||||
return Payload(self.REDIS, queue_name, group_name, msg_id, payload)
|
||||
except Exception as e:
|
||||
logging.warning("[EXCEPTION]xpending_range" + consumer_name + "||" + str(e))
|
||||
self.__open__()
|
||||
|
||||
REDIS_CONN = RedisDB()
|
||||
|
||||
Reference in New Issue
Block a user