From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 61FAB20965DED for ; Thu, 10 May 2018 08:14:59 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 May 2018 08:14:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,385,1520924400"; d="scan'208";a="54793356" Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.144]) by orsmga001.jf.intel.com with ESMTP; 10 May 2018 08:14:58 -0700 From: Jaben Carsey To: edk2-devel@lists.01.org Cc: Mike Kinney , Liming Gao , Yonghong Zhu Date: Thu, 10 May 2018 08:14:40 -0700 Message-Id: X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: Subject: [PATCH v2 1/1] BaseTools: loop to retry remove when it fails. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 15:14:59 -0000 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 Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- 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.
+# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.
# 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