Skip to content

Commit 903f459

Browse files
committed
Fix when multiple processes create __triton_launcher.pyd in parallel
1 parent c529c40 commit 903f459

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

python/triton/runtime/cache.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,15 @@ def put(self, data, filename, binary=True) -> str:
131131
f.write(data)
132132
# Replace is guaranteed to be atomic on POSIX systems if it succeeds
133133
# so filepath cannot see a partial write
134-
os.replace(temp_path, filepath)
134+
try:
135+
os.replace(temp_path, filepath)
136+
except PermissionError:
137+
# Ignore PermissionError on Windows because it happens when another process already
138+
# put a file into the cache and locked it by opening it.
139+
if os.name == "nt":
140+
os.remove(temp_path)
141+
else:
142+
raise
135143
os.removedirs(temp_dir)
136144
return filepath
137145

0 commit comments

Comments
 (0)