From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QLri5-0007yf-IX for garchives@archives.gentoo.org; Mon, 16 May 2011 06:55:21 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3F9731C009; Mon, 16 May 2011 06:55:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E9F361C009 for ; Mon, 16 May 2011 06:55:11 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 542491B4022 for ; Mon, 16 May 2011 06:55:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id C3E5B7448A for ; Mon, 16 May 2011 06:55:10 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <4ca3a0de43b6a7093f97330a31a76320db53f3f7.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/AsynchronousLock.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 4ca3a0de43b6a7093f97330a31a76320db53f3f7 Date: Mon, 16 May 2011 06:55:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: e594ddbace2d9861a953cf1998d6eebb commit: 4ca3a0de43b6a7093f97330a31a76320db53f3f7 Author: Zac Medico gentoo org> AuthorDate: Mon May 16 06:54:49 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Mon May 16 06:54:49 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D4ca3a0de _LockProcess: handle process failure more --- pym/_emerge/AsynchronousLock.py | 39 ++++++++++++++++++++++++++++-----= ------ 1 files changed, 28 insertions(+), 11 deletions(-) diff --git a/pym/_emerge/AsynchronousLock.py b/pym/_emerge/AsynchronousLo= ck.py index b62b684..1135df7 100644 --- a/pym/_emerge/AsynchronousLock.py +++ b/pym/_emerge/AsynchronousLock.py @@ -3,6 +3,7 @@ =20 import dummy_threading import fcntl +import logging import sys =20 try: @@ -13,7 +14,9 @@ except ImportError: import portage from portage import os from portage.exception import TryAgain +from portage.localization import _ from portage.locks import lockfile, unlockfile +from portage.util import writemsg_level from _emerge.AbstractPollTask import AbstractPollTask from _emerge.AsynchronousTask import AsynchronousTask from _emerge.PollConstants import PollConstants @@ -176,7 +179,7 @@ class _LockProcess(AbstractPollTask): """ =20 __slots__ =3D ('path', 'scheduler',) + \ - ('_proc', '_files', '_reg_id', '_unlocked') + ('_acquired', '_proc', '_files', '_reg_id', '_unlocked') =20 def _start(self): in_pr, in_pw =3D os.pipe() @@ -201,16 +204,29 @@ class _LockProcess(AbstractPollTask): os.close(in_pw) =20 def _proc_exit(self, proc): - if proc.returncode !=3D 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,)) + if proc.returncode !=3D os.EX_OK: + # Typically, this will happen due to the + # process being killed by a signal. + if not self._acquired: + # If the lock hasn't been aquired yet, the + # caller can check the returncode and handle + # this failure appropriately. + if not self.cancelled: + writemsg_level("_LockProcess: %s\n" % \ + _("failed to acquire lock on '%s'") % (self.path,), + level=3Dlogging.ERROR, noiselevel=3D-1) + self._unregister() + self.returncode =3D proc.returncode + self.wait() + return + + if not self.cancelled and \ + not self._unlocked: + # 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,)) =20 def _cancel(self): if self._proc is not None: @@ -226,6 +242,7 @@ class _LockProcess(AbstractPollTask): def _output_handler(self, f, event): buf =3D self._read_buf(self._files['pipe_in'], event) if buf: + self._acquired =3D True self._unregister() self.returncode =3D os.EX_OK self.wait()