From f3f88c6a3695755aafa3765219fa323fe46679d6 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 15 May 2011 01:03:14 -0700 Subject: [PATCH] EbuildPhase: AsynchronousLock for ebuild-locks --- pym/_emerge/EbuildPhase.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/pym/_emerge/EbuildPhase.py b/pym/_emerge/EbuildPhase.py index ff76fc641..0b4afe7e8 100644 --- a/pym/_emerge/EbuildPhase.py +++ b/pym/_emerge/EbuildPhase.py @@ -5,13 +5,12 @@ import gzip import sys import tempfile +from _emerge.AsynchronousLock import AsynchronousLock from _emerge.BinpkgEnvExtractor import BinpkgEnvExtractor from _emerge.MiscFunctionsProcess import MiscFunctionsProcess from _emerge.EbuildProcess import EbuildProcess from _emerge.CompositeTask import CompositeTask from portage.util import writemsg -from portage.locks import lockdir -from portage.locks import unlockdir from portage.xml.metadata import MetaDataXML import portage portage.proxy.lazyimport.lazyimport(globals(), @@ -121,6 +120,25 @@ class EbuildPhase(CompositeTask): self.wait() return + self._start_lock() + + def _start_lock(self): + if (self.phase in self._locked_phases and + "ebuild-locks" in self.settings.features): + eroot = self.settings["EROOT"] + lock_path = os.path.join(eroot, portage.VDB_PATH + "-ebuild") + if os.access(os.path.dirname(lock_path), os.W_OK): + self._ebuild_lock = AsynchronousLock(path=lock_path, + scheduler=self.scheduler) + self._start_task(self._ebuild_lock, self._lock_exit) + return + + self._start_ebuild() + + def _lock_exit(self, ebuild_lock): + if self._default_exit(ebuild_lock) != os.EX_OK: + self.wait() + return self._start_ebuild() def _start_ebuild(self): @@ -144,18 +162,12 @@ class EbuildPhase(CompositeTask): phase=self.phase, scheduler=self.scheduler, settings=self.settings) - if (self.phase in self._locked_phases and - "ebuild-locks" in self.settings.features): - eroot = self.settings["EROOT"] - lock_path = os.path.join(eroot, portage.VDB_PATH + "-ebuild") - if os.access(os.path.dirname(lock_path), os.W_OK): - self._ebuild_lock = lockdir(lock_path) self._start_task(ebuild_process, self._ebuild_exit) def _ebuild_exit(self, ebuild_process): if self._ebuild_lock is not None: - unlockdir(self._ebuild_lock) + self._ebuild_lock.unlock() self._ebuild_lock = None fail = False -- 2.26.2