Skip to content

Commit e58e077

Browse files
tadeleshCopilot
andauthored
Fix orphaned worker processes on changelog generation timeout (#46464)
When changelog generation times out, the multiprocessing pool worker and its child processes (azpysdk breaking) were not terminated, causing a race condition where the finally block deleted stable.json while orphaned processes were still running. This resulted in FileNotFoundError in the breaking change checker. Changes: - execute_func_with_timeout now properly calls pool.terminate() and pool.join() on timeout to kill worker processes before cleanup - Extended spec-pull-request timeout from 900s to 1800s for large packages like azure-mgmt-network Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 13e7deb commit e58e077

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

eng/tools/azure-sdk-tools/packaging_tools/sdk_changelog.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,22 @@ def is_arm_sdk(package_name: str) -> bool:
3939

4040

4141
def execute_func_with_timeout(func, timeout: int = 900) -> Any:
42-
"""Execute function with timeout"""
43-
return multiprocessing.Pool(processes=1).apply_async(func).get(timeout)
42+
"""Execute function with timeout.
43+
44+
On timeout, the worker pool is forcefully terminated to prevent orphaned
45+
child processes from continuing to run.
46+
"""
47+
pool = multiprocessing.Pool(processes=1)
48+
try:
49+
result = pool.apply_async(func)
50+
return result.get(timeout)
51+
except multiprocessing.TimeoutError:
52+
pool.terminate()
53+
pool.join()
54+
raise
55+
finally:
56+
pool.terminate()
57+
pool.join()
4458

4559

4660
def get_changelog_content(

eng/tools/azure-sdk-tools/packaging_tools/sdk_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def main(generate_input, generate_output):
219219
Path(sdk_code_path).absolute(),
220220
enable_changelog=data.get("enableChangelog", True),
221221
package_result=result[package_name],
222-
timeout=900 if data.get("runMode") in ["spec-pull-request"] else 7200,
222+
timeout=1800 if data.get("runMode") in ["spec-pull-request"] else 7200,
223223
)
224224

225225
# update version in _version.py and CHANGELOG.md

0 commit comments

Comments
 (0)