* [PATCH v2 1/1] BaseTools: loop to retry remove when it fails.
[not found] <cover.1525965238.git.jaben.carsey@intel.com>
@ 2018-05-10 15:14 ` Jaben Carsey
2018-05-25 11:08 ` Zhu, Yonghong
0 siblings, 1 reply; 2+ messages in thread
From: Jaben Carsey @ 2018-05-10 15:14 UTC (permalink / raw)
To: edk2-devel; +Cc: Mike Kinney, Liming Gao, Yonghong Zhu
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>
---
BaseTools/Source/Python/Common/LongFilePathOs.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 2e530f9dd774..2cebbb276b19 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))
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 1/1] BaseTools: loop to retry remove when it fails.
2018-05-10 15:14 ` [PATCH v2 1/1] BaseTools: loop to retry remove when it fails Jaben Carsey
@ 2018-05-25 11:08 ` Zhu, Yonghong
0 siblings, 0 replies; 2+ messages in thread
From: Zhu, Yonghong @ 2018-05-25 11:08 UTC (permalink / raw)
To: Carsey, Jaben, edk2-devel@lists.01.org
Cc: Kinney, Michael D, Gao, Liming, Zhu, Yonghong
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Thursday, May 10, 2018 11:15 PM
To: edk2-devel@lists.01.org
Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v2 1/1] 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>
---
BaseTools/Source/Python/Common/LongFilePathOs.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 2e530f9dd774..2cebbb276b19 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))
--
2.16.2.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-25 11:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1525965238.git.jaben.carsey@intel.com>
2018-05-10 15:14 ` [PATCH v2 1/1] BaseTools: loop to retry remove when it fails Jaben Carsey
2018-05-25 11:08 ` Zhu, Yonghong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox