diff --git a/api/core/helper/code_executor/code_executor.py b/api/core/helper/code_executor/code_executor.py index a96a2f1278..30d349838d 100644 --- a/api/core/helper/code_executor/code_executor.py +++ b/api/core/helper/code_executor/code_executor.py @@ -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: