diff options
author | Jaben Carsey <jaben.carsey@intel.com> | 2018-05-10 23:14:40 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-05-28 09:16:03 +0800 |
commit | efa88d51da7163200f13dfc796a328847c45a058 (patch) | |
tree | d24592fe8565c1cbda7f364db6daf9315a113d75 /BaseTools/Source | |
parent | 03ac238b1fe40cfbb1424bf72e2ac8276345e03c (diff) | |
download | edk2-efa88d51da7163200f13dfc796a328847c45a058.zip edk2-efa88d51da7163200f13dfc796a328847c45a058.tar.gz edk2-efa88d51da7163200f13dfc796a328847c45a058.tar.bz2 |
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>
Diffstat (limited to 'BaseTools/Source')
-rw-r--r-- | BaseTools/Source/Python/Common/LongFilePathOs.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py index 2e530f9..2cebbb2 100644 --- a/BaseTools/Source/Python/Common/LongFilePathOs.py +++ b/BaseTools/Source/Python/Common/LongFilePathOs.py @@ -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,7 +23,14 @@ def access(path, mode): return os.access(LongFilePath(path), mode)
def remove(path):
- return os.remove(LongFilePath(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):
return os.removedirs(LongFilePath(name))
|