summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/EbuildBuildDir.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-16 00:10:07 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-16 00:10:07 -0700
commitaeaa86486d9ea5a799c49bf8baa9a24a87ccb4de (patch)
tree45ffc6f060ea7bcd6169e63bf3997f3d707238c0 /pym/_emerge/EbuildBuildDir.py
parent4ca3a0de43b6a7093f97330a31a76320db53f3f7 (diff)
downloadportage-aeaa86486d9ea5a799c49bf8baa9a24a87ccb4de.tar.gz
portage-aeaa86486d9ea5a799c49bf8baa9a24a87ccb4de.tar.bz2
portage-aeaa86486d9ea5a799c49bf8baa9a24a87ccb4de.zip
EbuildBuildDir: handle AsynchronousLock failure
Diffstat (limited to 'pym/_emerge/EbuildBuildDir.py')
-rw-r--r--pym/_emerge/EbuildBuildDir.py27
1 files changed, 18 insertions, 9 deletions
diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py
index 1da3c93ae..3e0aefbf2 100644
--- a/pym/_emerge/EbuildBuildDir.py
+++ b/pym/_emerge/EbuildBuildDir.py
@@ -43,6 +43,8 @@ class EbuildBuildDir(SlotObject):
catdir_lock = AsynchronousLock(path=catdir, scheduler=self.scheduler)
catdir_lock.start()
catdir_lock.wait()
+ self._assert_lock(catdir_lock)
+
try:
try:
portage.util.ensure_dirs(catdir,
@@ -55,12 +57,19 @@ class EbuildBuildDir(SlotObject):
scheduler=self.scheduler)
builddir_lock.start()
builddir_lock.wait()
+ self._assert_lock(builddir_lock)
self._lock_obj = builddir_lock
self.settings['PORTAGE_BUILDIR_LOCKED'] = '1'
finally:
self.locked = self._lock_obj is not None
catdir_lock.unlock()
+ def _assert_lock(self, async_lock):
+ if async_lock.returncode != os.EX_OK:
+ # TODO: create a better way to propagate this error to the caller
+ raise AssertionError("AsynchronousLock failed with returncode %s" \
+ % (async_lock.returncode,))
+
def clean_log(self):
"""Discard existing log. The log will not be be discarded
in cases when it would not make sense, like when FEATURES=keepwork
@@ -85,15 +94,15 @@ class EbuildBuildDir(SlotObject):
self.settings.pop('PORTAGE_BUILDIR_LOCKED', None)
catdir_lock = AsynchronousLock(path=self._catdir, scheduler=self.scheduler)
catdir_lock.start()
- catdir_lock.wait()
- try:
- os.rmdir(self._catdir)
- except OSError as e:
- if e.errno not in (errno.ENOENT,
- errno.ENOTEMPTY, errno.EEXIST, errno.EPERM):
- raise
- finally:
- catdir_lock.unlock()
+ if catdir_lock.wait() == os.EX_OK:
+ try:
+ os.rmdir(self._catdir)
+ except OSError as e:
+ if e.errno not in (errno.ENOENT,
+ errno.ENOTEMPTY, errno.EEXIST, errno.EPERM):
+ raise
+ finally:
+ catdir_lock.unlock()
class AlreadyLocked(portage.exception.PortageException):
pass