Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Release db.session connection before workflow new thread long time operation (#21726)

Qiang Leecf2173644efd
diff --git a/api/core/app/apps/workflow/app_generator.py b/api/core/app/apps/workflow/app_generator.py
index 369fa0e48ce..a18139e6449 100644
--- a/api/core/app/apps/workflow/app_generator.py
+++ b/api/core/app/apps/workflow/app_generator.py
@@ -219,6 +219,9 @@ class WorkflowAppGenerator(BaseAppGenerator):
# new thread with request context and contextvars
context = contextvars.copy_context()
+ # release database connection, because the following new thread operations may take a long time
+ db.session.close()
+
worker_thread = threading.Thread(
target=self._generate_worker,
kwargs={