summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-13 20:01:16 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-13 20:01:16 -0700
commit0e4424f9963931bca7b67ed8652cf98581e0acd8 (patch)
treedf816d9571562c38340c62cddce97768e77b1d36
parentf6f71779b532ceec35021fb047b0c8db1806e65d (diff)
downloadportage-0e4424f9963931bca7b67ed8652cf98581e0acd8.tar.gz
portage-0e4424f9963931bca7b67ed8652cf98581e0acd8.tar.bz2
portage-0e4424f9963931bca7b67ed8652cf98581e0acd8.zip
Bug #336142 - Add support for using a thread to wait for locks inside
EbuildBuildDir.lock() so that the scheduler can concurrently service ipc calls in the main thread.
-rw-r--r--pym/_emerge/Binpkg.py2
-rw-r--r--pym/_emerge/EbuildBuild.py3
-rw-r--r--pym/_emerge/EbuildBuildDir.py19
3 files changed, 15 insertions, 9 deletions
diff --git a/pym/_emerge/Binpkg.py b/pym/_emerge/Binpkg.py
index ac9a68a0f..f50be6866 100644
--- a/pym/_emerge/Binpkg.py
+++ b/pym/_emerge/Binpkg.py
@@ -42,7 +42,7 @@ class Binpkg(CompositeTask):
dir_path = os.path.join(settings["PORTAGE_TMPDIR"],
"portage", pkg.category, pkg.pf)
self._build_dir = EbuildBuildDir(dir_path=dir_path,
- pkg=pkg, settings=settings)
+ pkg=pkg, scheduler=self.scheduler, settings=settings)
self._image_dir = os.path.join(dir_path, "image")
self._infloc = os.path.join(dir_path, "build-info")
self._ebuild_path = os.path.join(self._infloc, pkg.pf + ".ebuild")
diff --git a/pym/_emerge/EbuildBuild.py b/pym/_emerge/EbuildBuild.py
index 6d42b1fbb..c5241ffcd 100644
--- a/pym/_emerge/EbuildBuild.py
+++ b/pym/_emerge/EbuildBuild.py
@@ -114,7 +114,8 @@ class EbuildBuild(CompositeTask):
self.wait()
return
- self._build_dir = EbuildBuildDir(pkg=pkg, settings=settings)
+ self._build_dir = EbuildBuildDir(pkg=pkg,
+ scheduler=self.scheduler, settings=settings)
self._build_dir.lock()
# Cleaning needs to happen before fetch, since the build dir
diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py
index d9e471639..118001b5a 100644
--- a/pym/_emerge/EbuildBuildDir.py
+++ b/pym/_emerge/EbuildBuildDir.py
@@ -1,6 +1,7 @@
-# Copyright 1999-2009 Gentoo Foundation
+# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+from _emerge.AsynchronousLock import AsynchronousLock
from _emerge.SlotObject import SlotObject
import portage
from portage import os
@@ -8,7 +9,7 @@ import errno
class EbuildBuildDir(SlotObject):
- __slots__ = ("dir_path", "pkg", "settings",
+ __slots__ = ("dir_path", "pkg", "scheduler", "settings",
"locked", "_catdir", "_lock_obj")
def __init__(self, **kwargs):
@@ -47,17 +48,21 @@ class EbuildBuildDir(SlotObject):
portage.util.ensure_dirs(os.path.dirname(catdir),
gid=portage.portage_gid,
mode=0o70, mask=0)
- catdir_lock = None
+ catdir_lock = AsynchronousLock(path=catdir, scheduler=self.scheduler)
+ catdir_lock.start()
+ catdir_lock.wait()
try:
- catdir_lock = portage.locks.lockdir(catdir)
portage.util.ensure_dirs(catdir,
gid=portage.portage_gid,
mode=0o70, mask=0)
- self._lock_obj = portage.locks.lockdir(dir_path)
+ builddir_lock = AsynchronousLock(path=dir_path,
+ scheduler=self.scheduler)
+ builddir_lock.start()
+ builddir_lock.wait()
+ self._lock_obj = builddir_lock.lock_obj
finally:
self.locked = self._lock_obj is not None
- if catdir_lock is not None:
- portage.locks.unlockdir(catdir_lock)
+ catdir_lock.unlock()
def clean_log(self):
"""Discard existing log. The log will not be be discarded