From: Zac Medico Date: Mon, 16 May 2011 06:17:27 +0000 (-0700) Subject: _LockProcess: handle process failure if cancelled X-Git-Tag: v2.1.9.50~93 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=6c419c4b44a29efb22f37fd8f596043ef709395e;p=portage.git _LockProcess: handle process failure if cancelled --- 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