@@ -43,12 +43,15 @@ def execute_func_with_timeout(func, timeout: int = 900) -> Any:
4343 return multiprocessing .Pool (processes = 1 ).apply_async (func ).get (timeout )
4444
4545
46- def get_changelog_content (package_path : Path , package_result : dict , enable_changelog : bool ) -> tuple [str , str ]:
46+ def get_changelog_content (
47+ package_path : Path , package_result : dict , enable_changelog : bool , timeout : int = 900
48+ ) -> tuple [str , str ]:
4749 """Generate changelog content for the given package path.
4850 Args:
4951 package_path (Path): The path to the package directory.
5052 package_result (dict): The package result dictionary to store changelog info.
5153 enable_changelog (bool): Flag to enable or disable changelog generation.
54+ timeout (int): Timeout in seconds for changelog generation. Defaults to 900.
5255 Returns:
5356 tuple[str, str]: A tuple containing the generated markdown content and the last version.
5457 NOTE:
@@ -79,7 +82,7 @@ def get_changelog_content(package_path: Path, package_result: dict, enable_chang
7982
8083 try :
8184 if enable_changelog :
82- md_output = execute_func_with_timeout (change_log_func )
85+ md_output = execute_func_with_timeout (change_log_func , timeout )
8386 else :
8487 md_output = "skip changelog generation"
8588 except multiprocessing .TimeoutError :
@@ -104,7 +107,7 @@ def log_failed_message(message: str, enable_log_error: bool):
104107 _LOGGER .warning (message )
105108
106109
107- def main (package_path : Path , * , enable_changelog : bool = True , package_result : dict = {}):
110+ def main (package_path : Path , * , enable_changelog : bool = True , package_result : dict = {}, timeout : int = 900 ):
108111
109112 package_name = package_path .name
110113 # When package_result is provided, it means this function is called in pipeline and we should not log error
@@ -113,7 +116,7 @@ def main(package_path: Path, *, enable_changelog: bool = True, package_result: d
113116 # Changelog generation
114117 try :
115118 changelog_generation_start_time = time .time ()
116- md_output , last_version = get_changelog_content (package_path , package_result , enable_changelog )
119+ md_output , last_version = get_changelog_content (package_path , package_result , enable_changelog , timeout = timeout )
117120 _LOGGER .info (f"changelog generation cost time: { int (time .time () - changelog_generation_start_time )} seconds" )
118121 if package_result :
119122 package_result ["changelog" ] = {
@@ -183,6 +186,12 @@ def generate_main():
183186 required = True ,
184187 help = "Absolute path to the package directory (e.g. c:/azure-sdk-for-python/sdk/<service>/<package_name>)." ,
185188 )
189+ parser .add_argument (
190+ "--timeout" ,
191+ type = int ,
192+ default = 900 ,
193+ help = "Timeout in seconds for changelog generation (default: 900)." ,
194+ )
186195 parser .add_argument ("--debug" , dest = "debug" , action = "store_true" , help = "Enable DEBUG logging" )
187196
188197 args = parser .parse_args ()
@@ -198,7 +207,7 @@ def generate_main():
198207 if not package_path .is_absolute ():
199208 raise ValueError ("--package-path must be an absolute path" )
200209
201- main (package_path )
210+ main (package_path , timeout = args . timeout )
202211
203212
204213if __name__ == "__main__" :
0 commit comments