summaryrefslogtreecommitdiffstats
path: root/pym/_emerge/AsynchronousLock.py
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-15 23:17:27 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-15 23:17:27 -0700
commit0ee4c2b7195e03c828dc4f1ef85825509a5fe77a (patch)
tree32ae92f5a1ad2f5358efcc04be650dd5854bf93d /pym/_emerge/AsynchronousLock.py
parentb2e26ba79e1ef41594d1ec1bb032acf7fb6a1403 (diff)
downloadportage-0ee4c2b7195e03c828dc4f1ef85825509a5fe77a.tar.gz
portage-0ee4c2b7195e03c828dc4f1ef85825509a5fe77a.tar.bz2
portage-0ee4c2b7195e03c828dc4f1ef85825509a5fe77a.zip
_LockProcess: handle process failure if cancelled
Diffstat (limited to 'pym/_emerge/AsynchronousLock.py')
-rw-r--r--pym/_emerge/AsynchronousLock.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLock.py
index 6fa2bf632..b62b684f1 100644
--- a/pym/_emerge/AsynchronousLock.py
+++ b/pym/_emerge/AsynchronousLock.py
@@ -176,7 +176,7 @@ class _LockProcess(AbstractPollTask):
"""
__slots__ = ('path', 'scheduler',) + \
- ('_proc', '_files', '_reg_id')
+ ('_proc', '_files', '_reg_id', '_unlocked')
def _start(self):
in_pr, in_pw = os.pipe()
@@ -201,8 +201,14 @@ class _LockProcess(AbstractPollTask):
os.close(in_pw)
def _proc_exit(self, proc):
- if proc.returncode != os.EX_OK:
- # There's no good reason for locks to fail.
+ if proc.returncode != os.EX_OK and \
+ not self.cancelled and \
+ not self._unlocked:
+ # Typically, lock process failure should only happen
+ # if it's killed by a signal. We don't want lost
+ # locks going unnoticed, so it's only safe to ignore
+ # if either the cancel() or unlock() methods have
+ # been previously called.
raise AssertionError('lock process failed with returncode %s' \
% (proc.returncode,))
@@ -244,6 +250,7 @@ class _LockProcess(AbstractPollTask):
raise AssertionError('not locked')
if self.returncode is None:
raise AssertionError('lock not acquired yet')
+ self._unlocked = True
self._files['pipe_out'].write(b'\0')
self._files['pipe_out'].close()
self._files = None