Skip to content

Commit

Permalink
Fixed exception on windows when contention happens in file cache
Browse files Browse the repository at this point in the history
Signed-off-by: Gregory Shimansky <[email protected]>
  • Loading branch information
gshimansky committed Nov 21, 2024
1 parent 3dd760b commit 90138a1
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 90138a1

Please sign in to comment.