From acf55e672d32b5445cbe6e342feb814c3540e168 Mon Sep 17 00:00:00 2001 From: favilo Date: Mon, 25 Mar 2024 13:37:25 -0700 Subject: [PATCH] Conditionally use `onexc` for newer versions of python --- esrally/rally.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/esrally/rally.py b/esrally/rally.py index 5ef3c524c..786935b70 100644 --- a/esrally/rally.py +++ b/esrally/rally.py @@ -1266,8 +1266,11 @@ def _trap(function, path, exc_info): # fully destructive is fine, we only allow one Rally to run at a time and we will rely on the pip cache for download caching logger.info("Cleaning track dependency directory [%s]...", paths.libs()) - # pylint: disable=deprecated-argument - shutil.rmtree(paths.libs(), onerror=_trap) + if sys.version.major == 3 and sys.version.minor <= 11: + # pylint: disable=deprecated-argument + shutil.rmtree(paths.libs(), onerror=_trap) + else: + shutil.rmtree(paths.libs(), onexc=_trap) result = dispatch_sub_command(arg_parser, args, cfg)