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=michael.d.kinney@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 4F0E92083796C for ; Wed, 9 May 2018 16:47:17 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 16:47:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,383,1520924400"; d="scan'208";a="40028817" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga008.jf.intel.com with ESMTP; 09 May 2018 16:47:16 -0700 Received: from orsmsx156.amr.corp.intel.com (10.22.240.22) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 16:47:16 -0700 Received: from orsmsx113.amr.corp.intel.com ([169.254.9.220]) by ORSMSX156.amr.corp.intel.com ([169.254.8.42]) with mapi id 14.03.0319.002; Wed, 9 May 2018 16:47:15 -0700 From: "Kinney, Michael D" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" , "Kinney, Michael D" CC: "Gao, Liming" Thread-Topic: [edk2] [PATCH v1 1/1] BaseTools: loop to retry remove when it fails. Thread-Index: AQHT59eOfROoCzNEDESDjoSSKug/W6QoDyfg Date: Wed, 9 May 2018 23:47:15 +0000 Message-ID: References: <17f1054c0e2f87617110550f64c1bff62a33700c.1525899066.git.jaben.carsey@intel.com> In-Reply-To: <17f1054c0e2f87617110550f64c1bff62a33700c.1525899066.git.jaben.carsey@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Subject: Re: [PATCH v1 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: Wed, 09 May 2018 23:47:17 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Jaben, Instead of while TRUE, a timeout count be added so the loop can exit if the file is not released in a=20 reasonable period of time. Perhaps 5 seconds. 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)) Thanks, Mike > -----Original Message----- > From: edk2-devel [mailto:edk2-devel- > bounces@lists.01.org] On Behalf Of Jaben Carsey > Sent: Wednesday, May 9, 2018 1:51 PM > To: edk2-devel@lists.01.org > Cc: Gao, Liming > Subject: [edk2] [PATCH v1 1/1] BaseTools: loop to retry > remove when it fails. >=20 > There is a common race condition when the OS fails to > release a file > fast enough. this adds a retry loop. >=20 > Cc: Liming Gao > Cc: Yonghong Zhu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Jaben Carsey > --- > BaseTools/Source/Python/Common/LongFilePathOs.py | 9 > +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) >=20 > diff --git > a/BaseTools/Source/Python/Common/LongFilePathOs.py > b/BaseTools/Source/Python/Common/LongFilePathOs.py > index 2e530f9dd774..a595de2648b7 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 >=20 > path =3D LongFilePathOsPath >=20 > @@ -22,7 +23,11 @@ def access(path, mode): > return os.access(LongFilePath(path), mode) >=20 > def remove(path): > - return os.remove(LongFilePath(path)) > + while True: > + try: > + return os.remove(LongFilePath(path)) > + except: > + time.sleep(0.1) >=20 > def removedirs(name): > return os.removedirs(LongFilePath(name)) > -- > 2.16.2.windows.1 >=20 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel