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 1Ruu5V-0007ax-Bz for garchives@archives.gentoo.org; Tue, 07 Feb 2012 23:04:37 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 7EC87E0602; Tue, 7 Feb 2012 23:04:24 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3E954E05FC for ; Tue, 7 Feb 2012 23:04:24 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id ADC6B1B4029 for ; Tue, 7 Feb 2012 23:04:23 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 02A7580056 for ; Tue, 7 Feb 2012 23:04:23 +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: <445a6ea22c132f4c06c2cc7c48ec6e7af7116962.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/AbstractEbuildProcess.py pym/_emerge/SubProcess.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 445a6ea22c132f4c06c2cc7c48ec6e7af7116962 Date: Tue, 7 Feb 2012 23:04:23 +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: c5c32cf9-afc2-4350-9429-3a996a5c9b66 X-Archives-Hash: a1b9fb38d5d113684661341a08ab9219 commit: 445a6ea22c132f4c06c2cc7c48ec6e7af7116962 Author: Zac Medico gentoo org> AuthorDate: Tue Feb 7 02:58:51 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Feb 7 19:12:32 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D445a6ea2 Use timeout_add to avoid recursion, bug #402335. --- pym/_emerge/AbstractEbuildProcess.py | 37 ++++++++++++++++++++++++++--= ----- pym/_emerge/SubProcess.py | 6 ++++- 2 files changed, 34 insertions(+), 9 deletions(-) diff --git a/pym/_emerge/AbstractEbuildProcess.py b/pym/_emerge/AbstractE= buildProcess.py index 63368d4..5742cb2 100644 --- a/pym/_emerge/AbstractEbuildProcess.py +++ b/pym/_emerge/AbstractEbuildProcess.py @@ -19,7 +19,7 @@ from portage.util import apply_secpass_permissions class AbstractEbuildProcess(SpawnProcess): =20 __slots__ =3D ('phase', 'settings',) + \ - ('_build_dir', '_ipc_daemon', '_exit_command',) + ('_build_dir', '_ipc_daemon', '_exit_command', '_exit_timeout_id') _phases_without_builddir =3D ('clean', 'cleanrm', 'depend', 'help',) _phases_interactive_whitelist =3D ('config',) =20 @@ -157,13 +157,30 @@ class AbstractEbuildProcess(SpawnProcess): def _exit_command_callback(self): if self._registered: # Let the process exit naturally, if possible. - self.scheduler.schedule(self._reg_id, timeout=3Dself._exit_timeout) - if self._registered: - # If it doesn't exit naturally in a reasonable amount - # of time, kill it (solves bug #278895). We try to avoid - # this when possible since it makes sandbox complain about - # being killed by a signal. - self.cancel() + self._exit_timeout_id =3D \ + self.scheduler.timeout_add(self._exit_timeout, + self._exit_command_timeout_cb) + + def _exit_command_timeout_cb(self): + if self._registered: + # If it doesn't exit naturally in a reasonable amount + # of time, kill it (solves bug #278895). We try to avoid + # this when possible since it makes sandbox complain about + # being killed by a signal. + self.cancelled =3D True + self._cancel() + self._exit_timeout_id =3D \ + self.scheduler.timeout_add(self._cancel_timeout, + self._cancel_timeout_cb) + else: + self._exit_timeout_id =3D None + + return False # only run once + + def _cancel_timeout_cb(self): + self._exit_timeout_id =3D None + self.wait() + return False # only run once =20 def _orphan_process_warn(self): phase =3D self.phase @@ -253,6 +270,10 @@ class AbstractEbuildProcess(SpawnProcess): def _set_returncode(self, wait_retval): SpawnProcess._set_returncode(self, wait_retval) =20 + if self._exit_timeout_id is not None: + self.scheduler.source_remove(self._exit_timeout_id) + self._exit_timeout_id =3D None + if self._ipc_daemon is not None: self._ipc_daemon.cancel() if self._exit_command.exitcode is not None: diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 37922dc..c5cac7d 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -16,6 +16,10 @@ class SubProcess(AbstractPollTask): # serve this purpose alone. _dummy_pipe_fd =3D 9 =20 + # This is how much time we allow for waitpid to succeed after + # we've sent a kill signal to our subprocess. + _cancel_timeout =3D 1000 # 1 second + def _poll(self): if self.returncode is not None: return self.returncode @@ -60,7 +64,7 @@ class SubProcess(AbstractPollTask): =20 if self._registered: if self.cancelled: - timeout =3D 1000 + timeout =3D self._cancel_timeout self.scheduler.schedule(self._reg_id, timeout=3Dtimeout) if self._registered: try: