55import os
66from pathlib import Path
77from subprocess import check_call
8+ from typing import Any
9+ import multiprocessing
10+ from functools import partial
811
912from .package_utils import create_package , change_log_generate , extract_breaking_change
1013
1619_LOGGER = logging .getLogger (__name__ )
1720
1821
22+ def execute_func_with_timeout (func , timeout : int = 900 ) -> Any :
23+ """Execute function with timeout"""
24+ return multiprocessing .Pool (processes = 1 ).apply_async (func ).get (timeout )
25+
26+
1927def main (generate_input , generate_output ):
2028 with open (generate_input , "r" ) as reader :
2129 data = json .load (reader )
@@ -28,14 +36,18 @@ def main(generate_input, generate_output):
2836 prefolder = package ["path" ][0 ]
2937 # Changelog
3038 last_version = ["first release" ]
39+ change_log_func = partial (
40+ change_log_generate ,
41+ package_name ,
42+ last_version ,
43+ package ["tagIsStable" ],
44+ prefolder = prefolder ,
45+ is_multiapi = package ["isMultiapi" ],
46+ )
3147 try :
32- md_output = change_log_generate (
33- package_name ,
34- last_version ,
35- package ["tagIsStable" ],
36- prefolder = prefolder ,
37- is_multiapi = package ["isMultiapi" ],
38- )
48+ md_output = execute_func_with_timeout (change_log_func )
49+ except multiprocessing .TimeoutError :
50+ md_output = "change log generation was timeout!!!"
3951 except :
4052 md_output = "change log generation failed!!!"
4153 package ["changelog" ] = {
0 commit comments