[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:
@@ -378,6 +378,9 @@ def build_graphrag_for_kb(kb_id: uuid.UUID):
|
|||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"{datetime.now().strftime('%H:%M:%S')} GraphRAG task failed for task {task}:\n{str(e)}\n")
|
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)")
|
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."
|
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."
|
result = f"build knowledge grap '{db_knowledge.name}' failed."
|
||||||
return result
|
return result
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
if db:
|
||||||
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
@celery_app.task(name="app.core.rag.tasks.sync_knowledge_for_kb")
|
@celery_app.task(name="app.core.rag.tasks.sync_knowledge_for_kb")
|
||||||
|
|||||||
Reference in New Issue
Block a user