Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita61f794

Browse files
author
vshepard
committed
Fix node cleanup - rmdirs
1 parenta07f106 commita61f794

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

‎testgres/node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ def cleanup(self, max_attempts=3):
932932
else:
933933
rm_dir=self.data_dir# just data, save logs
934934

935-
self.os_ops.rmdirs(rm_dir,ignore_errors=True)
935+
self.os_ops.rmdirs(rm_dir,ignore_errors=False)
936936

937937
returnself
938938

‎testgres/operations/local_ops.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
importstat
55
importsubprocess
66
importtempfile
7+
importtime
78

89
importpsutil
910

@@ -147,8 +148,25 @@ def makedirs(self, path, remove_existing=False):
147148
exceptFileExistsError:
148149
pass
149150

150-
defrmdirs(self,path,ignore_errors=True):
151-
returnrmtree(path,ignore_errors=ignore_errors)
151+
defrmdirs(self,path,ignore_errors=True,retries=3,delay=1):
152+
"""
153+
Removes a directory and its contents, retrying on failure.
154+
155+
:param path: Path to the directory.
156+
:param ignore_errors: If True, ignore errors.
157+
:param retries: Number of attempts to remove the directory.
158+
:param delay: Delay between attempts in seconds.
159+
"""
160+
forattemptinrange(retries):
161+
try:
162+
rmtree(path,ignore_errors=ignore_errors)
163+
ifnotos.path.exists(path):
164+
returnTrue
165+
exceptExceptionase:
166+
print(f"Error: Failed to remove directory{path} on attempt{attempt+1}:{e}")
167+
time.sleep(delay)
168+
print(f"Error: Failed to remove directory{path} after{retries} attempts.")
169+
returnFalse
152170

153171
deflistdir(self,path):
154172
returnos.listdir(path)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp