From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id AD6FF1382C5 for ; Fri, 20 Apr 2018 16:18:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B3510E093A; Fri, 20 Apr 2018 16:18:33 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8F3B4E093A for ; Fri, 20 Apr 2018 16:18:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0F206335C7D for ; Fri, 20 Apr 2018 16:18:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ED2CE257 for ; Fri, 20 Apr 2018 16:18:29 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1524239381.0783351b0cb69fc33b984b1fe51e6c642c3bab7d.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/EbuildBuildDir.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 0783351b0cb69fc33b984b1fe51e6c642c3bab7d X-VCS-Branch: master Date: Fri, 20 Apr 2018 16:18:29 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 91c4f0a8-ad6e-4bff-9b13-a24cf4adf3bd X-Archives-Hash: e62f69dedd7764df778cd451b0f5e5a3 commit: 0783351b0cb69fc33b984b1fe51e6c642c3bab7d Author: Zac Medico gentoo org> AuthorDate: Thu Apr 19 16:12:00 2018 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Apr 20 15:49:41 2018 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0783351b EbuildBuildDir: add async_unlock method (bug 614108) Call the existing AsynchronousLock async_unlock method for the build directory lock, and also handle removal of the category directory (with async lock/unlock). Bug: https://bugs.gentoo.org/614108 pym/_emerge/EbuildBuildDir.py | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py index 58905c2f6..1f1385a3b 100644 --- a/pym/_emerge/EbuildBuildDir.py +++ b/pym/_emerge/EbuildBuildDir.py @@ -88,6 +88,9 @@ class EbuildBuildDir(SlotObject): if self._lock_obj is None: return + # Keep this legacy implementation until all consumers have migrated + # to async_unlock, since run_until_complete(self.async_unlock()) + # would add unwanted event loop recursion here. self._lock_obj.unlock() self._lock_obj = None self.locked = False @@ -102,6 +105,49 @@ class EbuildBuildDir(SlotObject): finally: catdir_lock.unlock() + def async_unlock(self): + """ + Release the lock asynchronously. Release notification is available + via the add_done_callback method of the returned Future instance. + + @returns: Future, result is None + """ + result = self.scheduler.create_future() + + def builddir_unlocked(future): + if future.exception() is not None: + result.set_exception(future.exception()) + else: + self._lock_obj = None + self.locked = False + self.settings.pop('PORTAGE_BUILDDIR_LOCKED', None) + catdir_lock = AsynchronousLock( + path=self._catdir, scheduler=self.scheduler) + catdir_lock.addExitListener(catdir_locked) + catdir_lock.start() + + def catdir_locked(catdir_lock): + if catdir_lock.wait() != os.EX_OK: + result.set_result(None) + else: + try: + os.rmdir(self._catdir) + except OSError: + pass + catdir_lock.async_unlock().add_done_callback(catdir_unlocked) + + def catdir_unlocked(future): + if future.exception() is None: + result.set_result(None) + else: + result.set_exception(future.exception()) + + if self._lock_obj is None: + self.scheduler.call_soon(result.set_result, None) + else: + self._lock_obj.async_unlock().add_done_callback(builddir_unlocked) + return result + class AlreadyLocked(portage.exception.PortageException): pass