Skip to content
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

Fixed exception on windows when contention happens in file cache #2787

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
10 changes: 9 additions & 1 deletion python/triton/runtime/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,15 @@ def put(self, data, filename, binary=True) -> str:
f.write(data)
# Replace is guaranteed to be atomic on POSIX systems if it succeeds
# so filepath cannot see a partial write
os.replace(temp_path, filepath)
try:
os.replace(temp_path, filepath)
except PermissionError:
# Ignore PermissionError on Windows because it happens when another process already
# put a file into the cache and locked it by opening it.
if os.name == "nt":
os.remove(temp_path)
else:
raise
os.removedirs(temp_dir)
return filepath

Expand Down