Merge pull request #1931 from danielaskdd/fix-first-stage-tasks-missing

Fix: Initialize first_stage_tasks and entity_relation_task to prevent empty-task cancel errors
This commit is contained in:
Daniel.y 2025-08-12 19:19:04 +08:00 committed by GitHub
commit 203e420b51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1229,6 +1229,9 @@ class LightRAG:
async with semaphore: async with semaphore:
nonlocal processed_count nonlocal processed_count
current_file_number = 0 current_file_number = 0
# Initialize to prevent UnboundLocalError in error handling
first_stage_tasks = []
entity_relation_task = None
try: try:
# Get file path from status document # Get file path from status document
file_path = getattr( file_path = getattr(
@ -1350,9 +1353,7 @@ class LightRAG:
# Cancel tasks that are not yet completed # Cancel tasks that are not yet completed
all_tasks = first_stage_tasks + ( all_tasks = first_stage_tasks + (
[entity_relation_task] [entity_relation_task] if entity_relation_task else []
if entity_relation_task
else []
) )
for task in all_tasks: for task in all_tasks:
if task and not task.done(): if task and not task.done():