Skip to content

Commit aed87ac

Browse files
authored
Fix read and write racing on multiple processes. (#1941)
Signed-off-by: Bernat Gabor <[email protected]>
1 parent 13c0498 commit aed87ac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

docs/changelog/1938.bugfix.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix a bug that reading and writing on the same file may cause race on multiple processes.

src/virtualenv/app_data/via_disk_folder.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,10 @@ def read(self):
137137
except Exception: # noqa
138138
pass
139139
if bad_format:
140-
self.remove()
140+
try:
141+
self.remove()
142+
except OSError: # reading and writing on the same file may cause race on multiple processes
143+
pass
141144
return None
142145

143146
def remove(self):

0 commit comments

Comments
 (0)