mirror of https://github.com/acidanthera/audk.git
BaseTools: loop to retry remove when it fails.
There is a common race condition when the OS fails to release a file fast enough. this adds a retry loop. v2 - Add a timeout. Cc: Mike Kinney <michael.d.kinney@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
parent
03ac238b1f
commit
efa88d51da
|
@ -1,7 +1,7 @@
|
|||
## @file
|
||||
# Override built in module os to provide support for long file path
|
||||
#
|
||||
# Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
|
||||
# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
|
||||
# This program and the accompanying materials
|
||||
# are licensed and made available under the terms and conditions of the BSD License
|
||||
# which accompanies this distribution. The full text of the license may be found at
|
||||
|
@ -15,6 +15,7 @@ import os
|
|||
import LongFilePathOsPath
|
||||
from Common.LongFilePathSupport import LongFilePath
|
||||
from Common.LongFilePathSupport import UniToStr
|
||||
import time
|
||||
|
||||
path = LongFilePathOsPath
|
||||
|
||||
|
@ -22,6 +23,13 @@ def access(path, mode):
|
|||
return os.access(LongFilePath(path), mode)
|
||||
|
||||
def remove(path):
|
||||
Timeout = 0.0
|
||||
while Timeout < 5.0:
|
||||
try:
|
||||
return os.remove(LongFilePath(path))
|
||||
except:
|
||||
time.sleep(0.1)
|
||||
Timeout = Timeout + 0.1
|
||||
return os.remove(LongFilePath(path))
|
||||
|
||||
def removedirs(name):
|
||||
|
|
Loading…
Reference in New Issue