[fix]A threading communication issue occurred when using the Trio asynchronous framework. The core error was OSError: [errno 9] Bad file descriptor, which occurred when Trio attempted to wake up the event loop in a multi-threaded environment

This commit is contained in:
lixiangcheng1
2026-02-24 16:53:07 +08:00
parent 26abf7b586
commit b462e17a5b

View File

@@ -378,6 +378,9 @@ def build_graphrag_for_kb(kb_id: uuid.UUID):
)
except Exception as e:
print(f"{datetime.now().strftime('%H:%M:%S')} GraphRAG task failed for task {task}:\n{str(e)}\n")
finally:
if db:
db.close()
print(f"{datetime.now().strftime('%H:%M:%S')} Knowledge Graph done ({time.time() - start_time}s)")
result = f"build knowledge graph '{db_knowledge.name}' processed successfully."
@@ -388,7 +391,8 @@ def build_graphrag_for_kb(kb_id: uuid.UUID):
result = f"build knowledge grap '{db_knowledge.name}' failed."
return result
finally:
db.close()
if db:
db.close()
@celery_app.task(name="app.core.rag.tasks.sync_knowledge_for_kb")