refactor: improve document clearing status management
- Use update() for atomic status updates - Improve history messages clearing while preserving list object
This commit is contained in:
@@ -998,13 +998,23 @@ def create_document_routes(
|
|||||||
message="Cannot clear documents while pipeline is busy",
|
message="Cannot clear documents while pipeline is busy",
|
||||||
)
|
)
|
||||||
# Set busy to true
|
# Set busy to true
|
||||||
pipeline_status["busy"] = True
|
pipeline_status.update(
|
||||||
pipeline_status["job_name"] = "Clearing Documents"
|
{
|
||||||
pipeline_status["latest_message"] = "Starting document clearing process"
|
"busy": True,
|
||||||
if "history_messages" in pipeline_status:
|
"job_name": "Clearing Documents",
|
||||||
pipeline_status["history_messages"].append(
|
"job_start": datetime.now().isoformat(),
|
||||||
"Starting document clearing process"
|
"docs": 0,
|
||||||
)
|
"batchs": 0,
|
||||||
|
"cur_batch": 0,
|
||||||
|
"request_pending": False, # Clear any previous request
|
||||||
|
"latest_message": "Starting document clearing process",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
# Cleaning history_messages without breaking it as a shared list object
|
||||||
|
del pipeline_status["history_messages"][:]
|
||||||
|
pipeline_status["history_messages"].append(
|
||||||
|
"Starting document clearing process"
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Use drop method to clear all data
|
# Use drop method to clear all data
|
||||||
|
Reference in New Issue
Block a user