Merge "Handle file removal concurrency"

This commit is contained in:
Zuul 2021-11-03 17:59:11 +00:00 committed by Gerrit Code Review
commit 7af23e5159
1 changed files with 8 additions and 4 deletions

View File

@ -124,10 +124,14 @@ def make_dir(dirname):
def remove_file(filename):
if os.path.isfile(filename):
LOG.debug("Remove file: '%s'", filename)
os.unlink(filename)
return True
else:
return False
try:
os.unlink(filename)
except FileNotFoundError:
LOG.debug("File concurrently removed: '%s'", filename)
else:
LOG.debug("File removed: '%s'", filename)
return True
return False
@contextlib.contextmanager