fix: close session before doing long latency operation (#22306)

This commit is contained in:
Jacky Wu
2025-07-14 11:16:10 +04:00
committed by GitHub
parent 6eb155ae69
commit 3e96c0c468
3 changed files with 11 additions and 3 deletions

View File

@@ -144,6 +144,8 @@ class KnowledgeRetrievalNode(LLMNode):
error=str(e),
error_type=type(e).__name__,
)
finally:
db.session.close()
def _fetch_dataset_retriever(self, node_data: KnowledgeRetrievalNodeData, query: str) -> list[dict[str, Any]]:
available_datasets = []
@@ -171,6 +173,9 @@ class KnowledgeRetrievalNode(LLMNode):
.all()
)
# avoid blocking at retrieval
db.session.close()
for dataset in results:
# pass if dataset is not available
if not dataset: