Skip to content

Commit

Permalink
multigpu rename error masking
Browse files Browse the repository at this point in the history
  • Loading branch information
bghira committed Dec 6, 2024
1 parent 80c263d commit 4b73d90
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions helpers/data_backend/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ def write(self, filepath: str, data: Any) -> None:
fcntl.flock(temp_file, fcntl.LOCK_UN)

# Atomically replace the target file with the temporary file
os.rename(temp_file_path, filepath)
try:
os.rename(temp_file_path, filepath)
except FileNotFoundError:
pass


def delete(self, filepath):
Expand Down Expand Up @@ -258,7 +261,10 @@ def torch_save(self, data, original_location):
# Release the lock
fcntl.flock(temp_file, fcntl.LOCK_UN)
# Atomically replace the target file with the temporary file
os.rename(temp_file_path, filepath)
try:
os.rename(temp_file_path, filepath)
except FileNotFoundError:
pass
else:
# Handle the case where original_location is a file object
temp_file = original_location
Expand Down

0 comments on commit 4b73d90

Please sign in to comment.