mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-04-19 04:30:01 +08:00
Fix: Ensure lock is released in update_progress using context manager (#6975)
ragflow: v0.17 also encountered this problem. #1453 The task table shows that the actual task has been completed. Since the process_msg of the task is not synchronized to the document table, there is no progress update on the page. This may be caused by the lock not being released when the exception occurs. ragflow:v0.17同样碰到这个问题, 看task表实际任务已经完成,由于没有把task的process_msg同步给document表, 所以在页面看没有进度更新。 可能是这里异常时没有释放锁导致的。 ```/api/ragflow_server.py def update_progress(): lock_value = str(uuid.uuid4()) redis_lock = RedisDistributedLock("update_progress", lock_value=lock_value, timeout=60) logging.info(f"update_progress lock_value: {lock_value}") while not stop_event.is_set(): try: if redis_lock.acquire(): DocumentService.update_progress() redis_lock.release() stop_event.wait(6) except Exception: logging.exception("update_progress exception") ++ if redis_lock.acquired: ++ redis_lock.release() ```
This commit is contained in:
parent
98670c3755
commit
b70abe52b2
@ -61,6 +61,8 @@ def update_progress():
|
|||||||
stop_event.wait(6)
|
stop_event.wait(6)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception("update_progress exception")
|
logging.exception("update_progress exception")
|
||||||
|
if redis_lock.acquired:
|
||||||
|
redis_lock.release()
|
||||||
|
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
logging.info("Received interrupt signal, shutting down...")
|
logging.info("Received interrupt signal, shutting down...")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user