yangdx
commited on
Commit
·
a1fbc3d
1
Parent(s):
e957265
refactor: improve document clearing status management
Browse files- Use update() for atomic status updates
- Improve history messages clearing while preserving list object
lightrag/api/routers/document_routes.py
CHANGED
@@ -998,13 +998,23 @@ def create_document_routes(
|
|
998 |
message="Cannot clear documents while pipeline is busy",
|
999 |
)
|
1000 |
# Set busy to true
|
1001 |
-
pipeline_status
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
"
|
1007 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1008 |
|
1009 |
try:
|
1010 |
# Use drop method to clear all data
|
|
|
998 |
message="Cannot clear documents while pipeline is busy",
|
999 |
)
|
1000 |
# Set busy to true
|
1001 |
+
pipeline_status.update(
|
1002 |
+
{
|
1003 |
+
"busy": True,
|
1004 |
+
"job_name": "Clearing Documents",
|
1005 |
+
"job_start": datetime.now().isoformat(),
|
1006 |
+
"docs": 0,
|
1007 |
+
"batchs": 0,
|
1008 |
+
"cur_batch": 0,
|
1009 |
+
"request_pending": False, # Clear any previous request
|
1010 |
+
"latest_message": "Starting document clearing process",
|
1011 |
+
}
|
1012 |
+
)
|
1013 |
+
# Cleaning history_messages without breaking it as a shared list object
|
1014 |
+
del pipeline_status["history_messages"][:]
|
1015 |
+
pipeline_status["history_messages"].append(
|
1016 |
+
"Starting document clearing process"
|
1017 |
+
)
|
1018 |
|
1019 |
try:
|
1020 |
# Use drop method to clear all data
|