Handle file removal concurrency
Change-Id: I976faf0f5f66403bdd4f0a01e7d9aef451db5003
This commit is contained in:
parent
dc57230764
commit
f841c0826b
@ -124,10 +124,14 @@ def make_dir(dirname):
|
|||||||
def remove_file(filename):
|
def remove_file(filename):
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
LOG.debug("Remove file: '%s'", filename)
|
LOG.debug("Remove file: '%s'", filename)
|
||||||
os.unlink(filename)
|
try:
|
||||||
return True
|
os.unlink(filename)
|
||||||
else:
|
except FileNotFoundError:
|
||||||
return False
|
LOG.debug("File concurrently removed: '%s'", filename)
|
||||||
|
else:
|
||||||
|
LOG.debug("File removed: '%s'", filename)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
|
Loading…
Reference in New Issue
Block a user