Hardcoded 60s Timeout in Python Environment Initialization Process #3

Closed
opened 2026-02-16 00:18:57 -05:00 by yindo · 2 comments
Owner

Originally created by @cFireworks on GitHub (Jan 11, 2025).

Title: Hardcoded 60s Timeout in Python Environment Initialization Process

Description:
This issue is related to dify: 1.0.0-beta.1 issue: Plugin Installation Fails Locally in Dify v1.0.0-beta.1: Infinite Retries and Unconfigurable Timeout

During the Python environment initialization process in the plugin manager, there is a hardcoded 60-second timeout that causes the initialization to fail if it exceeds this duration. This is defined in the following section of the code:

internal\core\plugin_manager\local_runtime\environment_python.go

routine.Submit(map[string]string{
	"module":   "plugin_manager",
	"function": "InitPythonEnvironment",
}, func() {
	ticker := time.NewTicker(5 * time.Second)
	defer ticker.Stop()
	for range ticker.C {
		if cmd.ProcessState != nil && cmd.ProcessState.Exited() {
			break
		}

		if time.Since(lastActiveAt) > 60*time.Second {
			cmd.Process.Kill()
			err_msg.WriteString("init process exited due to long time no activity")
			break
		}
	}
})

Problem:

  • The hardcoded timeout of 60 seconds in the Python environment initialization process results in a premature termination of the process if it takes longer than this period. This timeout may not be appropriate for certain environments where dependencies may take longer to install, particularly in slower or resource-constrained systems.
  • The environment initialization keeps retrying infinitely with a 30-second interval after a failure, posing a potential risk.

Expected Behavior:

  • The timeout should be configurable or extended beyond 60 seconds to accommodate environments where the initialization process may require more time, especially for large dependencies or slow networks.
  • The plugin installation should failed other than continuously retrying to reinstall.

Suggested Fix:

  • Allow the timeout to be configurable via an environment variable or configuration file.
  • Better retry mechanism

Additional Information:

This issue may result in the plugin installation process failing, especially in environments with limited resources or slower network connections. It would be beneficial to adjust this timeout to make the process more resilient and adaptable to different environments.

Originally created by @cFireworks on GitHub (Jan 11, 2025). **Title:** Hardcoded 60s Timeout in Python Environment Initialization Process **Description:** This issue is related to dify: 1.0.0-beta.1 issue: [Plugin Installation Fails Locally in Dify v1.0.0-beta.1: Infinite Retries and Unconfigurable Timeout](https://github.com/langgenius/dify/issues/12635) During the Python environment initialization process in the plugin manager, there is a hardcoded 60-second timeout that causes the initialization to fail if it exceeds this duration. This is defined in the following section of the code: > internal\core\plugin_manager\local_runtime\environment_python.go ```go routine.Submit(map[string]string{ "module": "plugin_manager", "function": "InitPythonEnvironment", }, func() { ticker := time.NewTicker(5 * time.Second) defer ticker.Stop() for range ticker.C { if cmd.ProcessState != nil && cmd.ProcessState.Exited() { break } if time.Since(lastActiveAt) > 60*time.Second { cmd.Process.Kill() err_msg.WriteString("init process exited due to long time no activity") break } } }) ``` ### Problem: - The hardcoded timeout of 60 seconds in the Python environment initialization process results in a premature termination of the process if it takes longer than this period. This timeout may not be appropriate for certain environments where dependencies may take longer to install, particularly in slower or resource-constrained systems. - The environment initialization keeps retrying infinitely with a 30-second interval after a failure, posing a potential risk. ### Expected Behavior: - The timeout should be configurable or extended beyond 60 seconds to accommodate environments where the initialization process may require more time, especially for large dependencies or slow networks. - The plugin installation should failed other than continuously retrying to reinstall. ### Suggested Fix: - Allow the timeout to be configurable via an environment variable or configuration file. - Better retry mechanism ### Additional Information: This issue may result in the plugin installation process failing, especially in environments with limited resources or slower network connections. It would be beneficial to adjust this timeout to make the process more resilient and adaptable to different environments.
yindo closed this issue 2026-02-16 00:18:57 -05:00
Author
Owner

@hjlarry commented on GitHub (Jan 13, 2025):

related PR https://github.com/langgenius/dify-plugin-daemon/pull/8
I havn't use the envrionment variable, just test 180s works for me.

@hjlarry commented on GitHub (Jan 13, 2025): related PR https://github.com/langgenius/dify-plugin-daemon/pull/8 I havn't use the envrionment variable, just test 180s works for me.
Author
Owner

@Yeuoly commented on GitHub (Jan 13, 2025):

resolved

@Yeuoly commented on GitHub (Jan 13, 2025): resolved
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-plugin-daemon#3