From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Mike Kinney <michael.d.kinney@intel.com>,
Liming Gao <liming.gao@intel.com>,
Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v2 1/1] BaseTools: loop to retry remove when it fails.
Date: Thu, 10 May 2018 08:14:40 -0700 [thread overview]
Message-ID: <ff66d9f75f8d7194774504bd63e0a1a4c32cd541.1525965238.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1525965238.git.jaben.carsey@intel.com>
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
next parent reply other threads:[~2018-05-10 15:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1525965238.git.jaben.carsey@intel.com>
2018-05-10 15:14 ` Jaben Carsey [this message]
2018-05-25 11:08 ` [PATCH v2 1/1] BaseTools: loop to retry remove when it fails Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ff66d9f75f8d7194774504bd63e0a1a4c32cd541.1525965238.git.jaben.carsey@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox