diff options
author | Zac Medico <zmedico@gentoo.org> | 2011-05-16 00:10:07 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-05-25 20:04:27 -0700 |
commit | 7e8cf234141ea5c1c86032b82e81c3c9640908ed (patch) | |
tree | 21efad0f342a5ac6e90bf1e40c7b8a5943d3782a /pym | |
parent | efe6d64295c5cf20869daac60a38651cb1158c51 (diff) | |
download | portage-7e8cf234141ea5c1c86032b82e81c3c9640908ed.tar.gz portage-7e8cf234141ea5c1c86032b82e81c3c9640908ed.tar.bz2 portage-7e8cf234141ea5c1c86032b82e81c3c9640908ed.zip |
EbuildBuildDir: handle AsynchronousLock failure
Diffstat (limited to 'pym')
-rw-r--r-- | pym/_emerge/EbuildBuildDir.py | 27 |
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 |