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.115; helo=mga14.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (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 CE688207E5401 for ; Fri, 25 May 2018 04:08:36 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 May 2018 04:08:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,439,1520924400"; d="scan'208";a="44680499" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga006.jf.intel.com with ESMTP; 25 May 2018 04:08:36 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 25 May 2018 04:08:35 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 25 May 2018 04:08:35 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.96]) with mapi id 14.03.0319.002; Fri, 25 May 2018 19:08:33 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v2 1/1] BaseTools: loop to retry remove when it fails. Thread-Index: AQHT6HGtzWhGmNPKrEyD8ThQwQ2fRKRAYHQA Date: Fri, 25 May 2018 11:08:33 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Fri, 25 May 2018 11:08:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Thursday, May 10, 2018 11:15 PM To: edk2-devel@lists.01.org Cc: Kinney, Michael D ; Gao, Liming ; Zhu, Yonghong 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 e= nough. 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/S= ource/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=20 +reserved.
# This program and the accompanying materials # are licensed and made ava= ilable under the terms and conditions of the BSD License # which accompani= es this distribution. The full text of the license may be found at @@ -15,= 6 +15,7 @@ import os import LongFilePathOsPath from Common.LongFilePathSu= pport import LongFilePath from Common.LongFilePathSupport import UniToStr +import time =20 path =3D LongFilePathOsPath =20 @@ -22,7 +23,14 @@ def access(path, mode): return os.access(LongFilePath(path), mode) =20 def remove(path): - return os.remove(LongFilePath(path)) + Timeout =3D 0.0 + while Timeout < 5.0: + try: + return os.remove(LongFilePath(path)) + except: + time.sleep(0.1) + Timeout =3D Timeout + 0.1 + return os.remove(LongFilePath(path)) =20 def removedirs(name): return os.removedirs(LongFilePath(name)) -- 2.16.2.windows.1