Skip to content

Commit

Permalink
Fixed race condition (lbl-srg#392)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter authored Nov 18, 2020
1 parent 7f35d83 commit 954f235
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion buildingspy/io/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ def deleteLogFile(self):
"""
import os
if os.path.isfile(self._logFil):
os.remove(self._logFil)
# The try-except below guards against a race condition if multiple
# processes start and they try to delete the file at the same time.
try:
os.remove(self._logFil)
except FileNotFoundError:
print(f"Failed to remove {self._logFil} as it no longer exists.")

def logToFile(self, log=True):
""" Function to log the standard output and standard error stream to a file.
Expand Down

0 comments on commit 954f235

Please sign in to comment.