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

Fix node cleanup#135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
demonolock merged 3 commits intomasterfromfix-node-cleanup
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Fix node cleanup - rmdirs
  • Loading branch information
vshepard committedJun 30, 2024
commita61f794c0f6e246908679d805035bde6418b76ad
2 changes: 1 addition & 1 deletiontestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -932,7 +932,7 @@ def cleanup(self, max_attempts=3):
else:
rm_dir = self.data_dir # just data, save logs

self.os_ops.rmdirs(rm_dir, ignore_errors=True)
self.os_ops.rmdirs(rm_dir, ignore_errors=False)

return self

Expand Down
22 changes: 20 additions & 2 deletionstestgres/operations/local_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
import stat
import subprocess
import tempfile
import time

import psutil

Expand DownExpand Up@@ -147,8 +148,25 @@ def makedirs(self, path, remove_existing=False):
except FileExistsError:
pass

def rmdirs(self, path, ignore_errors=True):
return rmtree(path, ignore_errors=ignore_errors)
def rmdirs(self, path, ignore_errors=True, retries=3, delay=1):
"""
Removes a directory and its contents, retrying on failure.

:param path: Path to the directory.
:param ignore_errors: If True, ignore errors.
:param retries: Number of attempts to remove the directory.
:param delay: Delay between attempts in seconds.
"""
for attempt in range(retries):
try:
rmtree(path, ignore_errors=ignore_errors)
if not os.path.exists(path):
return True
except Exception as e:
print(f"Error: Failed to remove directory {path} on attempt {attempt + 1}: {e}")
time.sleep(delay)
print(f"Error: Failed to remove directory {path} after {retries} attempts.")
return False

def listdir(self, path):
return os.listdir(path)
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp