mirror of https://github.com/langgenius/dify.git
fix: set code execution timeout
This commit is contained in:
parent
5ff2fbed59
commit
ac63b5385a
|
|
@ -13,6 +13,8 @@ from core.helper.code_executor.python_transformer import PythonTemplateTransform
|
|||
CODE_EXECUTION_ENDPOINT = environ.get('CODE_EXECUTION_ENDPOINT', '')
|
||||
CODE_EXECUTION_API_KEY = environ.get('CODE_EXECUTION_API_KEY', '')
|
||||
|
||||
CODE_EXECUTION_TIMEOUT= (10, 60)
|
||||
|
||||
class CodeExecutionException(Exception):
|
||||
pass
|
||||
|
||||
|
|
@ -58,7 +60,7 @@ class CodeExecutor:
|
|||
}
|
||||
|
||||
try:
|
||||
response = post(str(url), json=data, headers=headers)
|
||||
response = post(str(url), json=data, headers=headers, timeout=CODE_EXECUTION_TIMEOUT)
|
||||
if response.status_code == 503:
|
||||
raise CodeExecutionException('Code execution service is unavailable')
|
||||
elif response.status_code != 200:
|
||||
|
|
|
|||
Loading…
Reference in New Issue