CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
56 lines
1.7 KiB
Python
56 lines
1.7 KiB
Python
# Copyright Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
"""OS-level utility functions.
|
|
|
|
These include workarounds for platform-specific quirks, particularly Windows
|
|
file locking.
|
|
"""
|
|
|
|
from pathlib import Path
|
|
import shutil
|
|
import sys
|
|
import time
|
|
|
|
# Maximum number of attempts to retry removing a directory.
|
|
RMTREE_MAX_ATTEMPTS: int = 10
|
|
# Base delay between retry attempts in seconds (multiplied by attempt + 2).
|
|
RMTREE_RETRY_DELAY_SECONDS: float = 0.5
|
|
|
|
|
|
def rmtree_with_retry(
|
|
path: Path,
|
|
*,
|
|
verbose: bool = False,
|
|
max_attempts: int = RMTREE_MAX_ATTEMPTS,
|
|
retry_delay_seconds: float = RMTREE_RETRY_DELAY_SECONDS,
|
|
) -> None:
|
|
"""Remove a directory tree, retrying on PermissionError (e.g. Windows locks).
|
|
|
|
On Windows, files may be temporarily locked by antivirus scanners, search
|
|
indexers, or other processes. A short retry loop avoids flaky failures in
|
|
CI builds where parallel jobs can hold transient file handles.
|
|
"""
|
|
for attempt in range(max_attempts):
|
|
try:
|
|
shutil.rmtree(path)
|
|
if verbose:
|
|
print(f"rmtree {path}", file=sys.stderr)
|
|
return
|
|
except PermissionError:
|
|
wait_time = retry_delay_seconds * (attempt + 2)
|
|
if verbose:
|
|
print(
|
|
f"PermissionError calling shutil.rmtree('{path}') "
|
|
f"retrying after {wait_time}s",
|
|
file=sys.stderr,
|
|
)
|
|
time.sleep(wait_time)
|
|
if attempt == max_attempts - 1:
|
|
if verbose:
|
|
print(
|
|
f"rmtree failed after {max_attempts} attempts, failing",
|
|
file=sys.stderr,
|
|
)
|
|
raise
|