Skip to content

Commit c2de984

Browse files
authored
donate_cpu_lib.py: use try_retry() in __remove_tree() (danmar#4715)
1 parent 7876e10 commit c2de984

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

tools/donate_cpu_lib.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# Version scheme (MAJOR.MINOR.PATCH) should orientate on "Semantic Versioning" https://semver.org/
1616
# Every change in this script should result in increasing the version number accordingly (exceptions may be cosmetic
1717
# changes)
18-
CLIENT_VERSION = "1.3.41"
18+
CLIENT_VERSION = "1.3.42"
1919

2020
# Timeout for analysis with Cppcheck in seconds
2121
CPPCHECK_TIMEOUT = 30 * 60
@@ -291,18 +291,16 @@ def __handle_remove_readonly(func, path, exc):
291291
def __remove_tree(folder_name):
292292
if not os.path.exists(folder_name):
293293
return
294+
295+
def rmtree_func():
296+
shutil.rmtree(folder_name, onerror=__handle_remove_readonly)
297+
294298
print('Removing existing temporary data...')
295-
count = 5
296-
while count > 0:
297-
count -= 1
298-
try:
299-
shutil.rmtree(folder_name, onerror=__handle_remove_readonly)
300-
break
301-
except OSError as err:
302-
time.sleep(30)
303-
if count == 0:
304-
print('Failed to cleanup {}: {}'.format(folder_name, err))
305-
sys.exit(1)
299+
try:
300+
try_retry(rmtree_func, max_tries=5, sleep_duration=30, sleep_factor=1)
301+
except Exception as e:
302+
print('Failed to cleanup {}: {}'.format(folder_name, e))
303+
sys.exit(1)
306304

307305

308306
def __wget(url, destfile, bandwidth_limit):

0 commit comments

Comments
 (0)