-
Notifications
You must be signed in to change notification settings - Fork 52
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rmtree for nfs #2434
base: main
Are you sure you want to change the base?
Rmtree for nfs #2434
Changes from 5 commits
55f503c
9e72d24
c1be5ab
1952c18
b13b9ff
5a18a31
8069d40
49f3756
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,13 @@ | |
|
||
from __future__ import annotations | ||
|
||
import errno | ||
import logging | ||
import os | ||
import shutil | ||
import time | ||
from pathlib import Path | ||
from shutil import move, rmtree | ||
from shutil import move | ||
from typing import TYPE_CHECKING | ||
|
||
from monty.shutil import gzip_dir | ||
|
@@ -174,3 +177,25 @@ | |
symlink_path.symlink_to(job_failed_dir, target_is_directory=True) | ||
|
||
raise JobFailure(job_failed_dir, message=msg, parent_error=exception) from exception | ||
|
||
|
||
def rmtree(*args, max_retries=3, retry_wait=10, **kwargs): | ||
""" | ||
rmtree that will retry if we get common NFS errors (files still being deleted, etc) | ||
Adapted from https://github.com/teojgo/reframe/blob/master/reframe/utility/osext.py | ||
""" | ||
Comment on lines
+182
to
+186
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we can have some docstrings and type hints here, that would be greatly appreciated. For instance, it's not immediately clear what |
||
if "onerror" in kwargs and kwargs["onerror"] is not None: | ||
shutil.rmtree(*args, **kwargs) | ||
return | ||
|
||
for i in range(max_retries): | ||
try: | ||
shutil.rmtree(*args, **kwargs) | ||
return | ||
except OSError as e: | ||
if i == max_retries: | ||
raise | ||
Comment on lines
+196
to
+197
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we raise a specific exception and have a useful message? |
||
elif e.errno in {errno.ENOTEMPTY, errno.EBUSY}: | ||
time.sleep(retry_wait) | ||
else: | ||
raise | ||
Comment on lines
+200
to
+201
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here with the exception to raise. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're good with a 10 s default? Not too long for you?