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.

feat: introduce APP_MAX_EXECUTION_TIME (#5167)

Yeuoly0cccf9c67d24
diff --git a/api/.env.example b/api/.env.example
index bee62cfe0bc..571f5b168ea 100644
--- a/api/.env.example
+++ b/api/.env.example
@@ -203,3 +203,6 @@ INDEXING_MAX_SEGMENTATION_TOKENS_LENGTH=1000
WORKFLOW_MAX_EXECUTION_STEPS=500
WORKFLOW_MAX_EXECUTION_TIME=1200
WORKFLOW_CALL_MAX_DEPTH=5
+
+# App configuration
+APP_MAX_EXECUTION_TIME=1200
\ No newline at end of file
diff --git a/api/config.py b/api/config.py
index bb9f85781e5..53cc6ce393b 100644
--- a/api/config.py
+++ b/api/config.py
@@ -85,6 +85,7 @@ DEFAULTS = {
'WORKFLOW_MAX_EXECUTION_STEPS': 500,
'WORKFLOW_MAX_EXECUTION_TIME': 1200,
'WORKFLOW_CALL_MAX_DEPTH': 5,
+ 'APP_MAX_EXECUTION_TIME': 1200,
}
@@ -372,6 +373,7 @@ class Config:
self.WORKFLOW_MAX_EXECUTION_STEPS = int(get_env('WORKFLOW_MAX_EXECUTION_STEPS'))
self.WORKFLOW_MAX_EXECUTION_TIME = int(get_env('WORKFLOW_MAX_EXECUTION_TIME'))
self.WORKFLOW_CALL_MAX_DEPTH = int(get_env('WORKFLOW_CALL_MAX_DEPTH'))
+ self.APP_MAX_EXECUTION_TIME = int(get_env('APP_MAX_EXECUTION_TIME'))
# Moderation in app Configurations.
self.OUTPUT_MODERATION_BUFFER_SIZE = int(get_env('OUTPUT_MODERATION_BUFFER_SIZE'))
diff --git a/api/core/app/apps/base_app_queue_manager.py b/api/core/app/apps/base_app_queue_manager.py
index 43a44819f94..eff07cc071d 100644
--- a/api/core/app/apps/base_app_queue_manager.py
+++ b/api/core/app/apps/base_app_queue_manager.py
@@ -5,6 +5,7 @@ from collections.abc import Generator
from enum import Enum
from typing import Any
+from flask import current_app
from sqlalchemy.orm import DeclarativeMeta
from core.app.entities.app_invoke_entities import InvokeFrom
@@ -46,8 +47,8 @@ class AppQueueManager:
Listen to queue
:return:
"""
- # wait for 10 minutes to stop listen
- listen_timeout = 600
+ # wait for APP_MAX_EXECUTION_TIME seconds to stop listen
+ listen_timeout = current_app.config.get("APP_MAX_EXECUTION_TIME")
start_time = time.time()
last_ping_time = 0