yangdx commited on
Commit
a878053
·
1 Parent(s): 739197c

Fix history_messages clearing in LightRAG pipeline status initialization

Browse files
Files changed (1) hide show
  1. lightrag/lightrag.py +6 -6
lightrag/lightrag.py CHANGED
@@ -710,11 +710,6 @@ class LightRAG:
710
  async with pipeline_status_lock:
711
  # Ensure only one worker is processing documents
712
  if not pipeline_status.get("busy", False):
713
- # Cleaning history_messages without breaking it as a shared list object
714
- current_history = pipeline_status.get("history_messages", [])
715
- if hasattr(current_history, "clear"):
716
- current_history.clear()
717
-
718
  pipeline_status.update(
719
  {
720
  "busy": True,
@@ -725,9 +720,14 @@ class LightRAG:
725
  "cur_batch": 0,
726
  "request_pending": False, # Clear any previous request
727
  "latest_message": "",
728
- "history_messages": current_history, # keep it as a shared list object
729
  }
730
  )
 
 
 
 
 
 
731
  process_documents = True
732
  else:
733
  # Another process is busy, just set request flag and return
 
710
  async with pipeline_status_lock:
711
  # Ensure only one worker is processing documents
712
  if not pipeline_status.get("busy", False):
 
 
 
 
 
713
  pipeline_status.update(
714
  {
715
  "busy": True,
 
720
  "cur_batch": 0,
721
  "request_pending": False, # Clear any previous request
722
  "latest_message": "",
 
723
  }
724
  )
725
+ # Cleaning history_messages without breaking it as a shared list object
726
+ try:
727
+ del pipeline_status["history_messages"][:]
728
+ except Exception as e:
729
+ logger.error(f"Error clearing pipeline history_messages: {str(e)}")
730
+
731
  process_documents = True
732
  else:
733
  # Another process is busy, just set request flag and return