mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-15 01:56:01 +08:00
Make max_submit_count configurable via Config (#11673)
This commit is contained in:
parent
79801f5c30
commit
63f1dd7877
@ -433,3 +433,5 @@ RESET_PASSWORD_TOKEN_EXPIRY_MINUTES=5
|
|||||||
|
|
||||||
CREATE_TIDB_SERVICE_JOB_ENABLED=false
|
CREATE_TIDB_SERVICE_JOB_ENABLED=false
|
||||||
|
|
||||||
|
# Maximum number of submitted thread count in a ThreadPool for parallel node execution
|
||||||
|
MAX_SUBMIT_COUNT=100
|
||||||
|
@ -439,6 +439,17 @@ class WorkflowConfig(BaseSettings):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class WorkflowNodeExecutionConfig(BaseSettings):
|
||||||
|
"""
|
||||||
|
Configuration for workflow node execution
|
||||||
|
"""
|
||||||
|
|
||||||
|
MAX_SUBMIT_COUNT: PositiveInt = Field(
|
||||||
|
description="Maximum number of submitted thread count in a ThreadPool for parallel node execution",
|
||||||
|
default=100,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class AuthConfig(BaseSettings):
|
class AuthConfig(BaseSettings):
|
||||||
"""
|
"""
|
||||||
Configuration for authentication and OAuth
|
Configuration for authentication and OAuth
|
||||||
@ -775,6 +786,7 @@ class FeatureConfig(
|
|||||||
ToolConfig,
|
ToolConfig,
|
||||||
UpdateConfig,
|
UpdateConfig,
|
||||||
WorkflowConfig,
|
WorkflowConfig,
|
||||||
|
WorkflowNodeExecutionConfig,
|
||||||
WorkspaceConfig,
|
WorkspaceConfig,
|
||||||
LoginConfig,
|
LoginConfig,
|
||||||
# hosted services config
|
# hosted services config
|
||||||
|
@ -9,6 +9,7 @@ from typing import Any, Optional, cast
|
|||||||
|
|
||||||
from flask import Flask, current_app
|
from flask import Flask, current_app
|
||||||
|
|
||||||
|
from configs import dify_config
|
||||||
from core.app.apps.base_app_queue_manager import GenerateTaskStoppedError
|
from core.app.apps.base_app_queue_manager import GenerateTaskStoppedError
|
||||||
from core.app.entities.app_invoke_entities import InvokeFrom
|
from core.app.entities.app_invoke_entities import InvokeFrom
|
||||||
from core.workflow.entities.node_entities import NodeRunMetadataKey, NodeRunResult
|
from core.workflow.entities.node_entities import NodeRunMetadataKey, NodeRunResult
|
||||||
@ -52,7 +53,12 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
class GraphEngineThreadPool(ThreadPoolExecutor):
|
class GraphEngineThreadPool(ThreadPoolExecutor):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, max_workers=None, thread_name_prefix="", initializer=None, initargs=(), max_submit_count=100
|
self,
|
||||||
|
max_workers=None,
|
||||||
|
thread_name_prefix="",
|
||||||
|
initializer=None,
|
||||||
|
initargs=(),
|
||||||
|
max_submit_count=dify_config.MAX_SUBMIT_COUNT,
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__(max_workers, thread_name_prefix, initializer, initargs)
|
super().__init__(max_workers, thread_name_prefix, initializer, initargs)
|
||||||
self.max_submit_count = max_submit_count
|
self.max_submit_count = max_submit_count
|
||||||
@ -92,7 +98,7 @@ class GraphEngine:
|
|||||||
max_execution_time: int,
|
max_execution_time: int,
|
||||||
thread_pool_id: Optional[str] = None,
|
thread_pool_id: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
thread_pool_max_submit_count = 100
|
thread_pool_max_submit_count = dify_config.MAX_SUBMIT_COUNT
|
||||||
thread_pool_max_workers = 10
|
thread_pool_max_workers = 10
|
||||||
|
|
||||||
# init thread pool
|
# init thread pool
|
||||||
|
@ -163,7 +163,9 @@ class IterationNode(BaseNode[IterationNodeData]):
|
|||||||
if self.node_data.is_parallel:
|
if self.node_data.is_parallel:
|
||||||
futures: list[Future] = []
|
futures: list[Future] = []
|
||||||
q: Queue = Queue()
|
q: Queue = Queue()
|
||||||
thread_pool = GraphEngineThreadPool(max_workers=self.node_data.parallel_nums, max_submit_count=100)
|
thread_pool = GraphEngineThreadPool(
|
||||||
|
max_workers=self.node_data.parallel_nums, max_submit_count=dify_config.MAX_SUBMIT_COUNT
|
||||||
|
)
|
||||||
for index, item in enumerate(iterator_list_value):
|
for index, item in enumerate(iterator_list_value):
|
||||||
future: Future = thread_pool.submit(
|
future: Future = thread_pool.submit(
|
||||||
self._run_single_iter_parallel,
|
self._run_single_iter_parallel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user