@@ -42,17 +42,23 @@ def print_inputs(render_context, existing_files_content, message):
4242
4343
4444def execute_script (
45- script : str , scripts_args : list [str ], verbose : bool , script_type : str , frid : Optional [str ] = None
45+ script : str ,
46+ scripts_args : list [str ],
47+ verbose : bool ,
48+ script_type : str ,
49+ frid : Optional [str ] = None ,
50+ timeout : Optional [int ] = None ,
4651) -> tuple [int , str , Optional [str ]]:
4752 temp_file_path = None
53+ script_timeout = timeout if timeout is not None else SCRIPT_EXECUTION_TIMEOUT
4854 try :
4955 start_time = time .time ()
5056 result = subprocess .run (
5157 [file_utils .add_current_path_if_no_path (script )] + scripts_args ,
5258 stdout = subprocess .PIPE ,
5359 stderr = subprocess .STDOUT ,
5460 text = True ,
55- timeout = SCRIPT_EXECUTION_TIMEOUT ,
61+ timeout = script_timeout ,
5662 )
5763 elapsed_time = time .time () - start_time
5864 # Log the info about the script execution
@@ -90,19 +96,19 @@ def execute_script(
9096 # Store timeout output in a temporary file
9197 if verbose :
9298 with tempfile .NamedTemporaryFile (mode = "w+" , delete = False , suffix = ".script_timeout" ) as temp_file :
93- temp_file .write (f"{ script_type } script { script } timed out after { SCRIPT_EXECUTION_TIMEOUT } seconds." )
99+ temp_file .write (f"{ script_type } script { script } timed out after { script_timeout } seconds." )
94100 if e .stdout :
95101 decoded_output = e .stdout .decode ("utf-8" ) if isinstance (e .stdout , bytes ) else e .stdout
96102 temp_file .write (f"{ script_type } script partial output before the timeout:\n { decoded_output } " )
97103 else :
98104 temp_file .write (f"{ script_type } script did not produce any output before the timeout." )
99105 temp_file_path = temp_file .name
100106 console .warning (
101- f"The { script_type } script timed out after { SCRIPT_EXECUTION_TIMEOUT } seconds. { script_type } script output stored in: { temp_file_path } "
107+ f"The { script_type } script timed out after { script_timeout } seconds. { script_type } script output stored in: { temp_file_path } "
102108 )
103109
104110 return (
105111 TIMEOUT_ERROR_EXIT_CODE ,
106- f"{ script_type } script did not finish in { SCRIPT_EXECUTION_TIMEOUT } seconds." ,
112+ f"{ script_type } script did not finish in { script_timeout } seconds." ,
107113 temp_file_path ,
108114 )
0 commit comments