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 1Ry8RQ-0004sN-4c for garchives@archives.gentoo.org; Thu, 16 Feb 2012 21:00:36 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 71DEFE0FAA; Thu, 16 Feb 2012 21:00:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 412AEE0FAA for ; Thu, 16 Feb 2012 21:00:28 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 71EDE1B4022 for ; Thu, 16 Feb 2012 21:00:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 622E9E5404 for ; Thu, 16 Feb 2012 21:00:16 +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: <1329425957.1979a6cdfcd8c6bae4565982d82d862be07ba5be.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/SubProcess.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 1979a6cdfcd8c6bae4565982d82d862be07ba5be X-VCS-Branch: master Date: Thu, 16 Feb 2012 21:00:16 +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: b01b9a31-3717-4a4f-a593-5c68e831b363 X-Archives-Hash: 4a59313b1a5074890469433c4a7f76b8 commit: 1979a6cdfcd8c6bae4565982d82d862be07ba5be Author: Zac Medico gentoo org> AuthorDate: Thu Feb 16 20:58:29 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu Feb 16 20:59:17 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D1979a6cd SubProcess: use child_watch_add This fixes performance issues introduced by commit 9c664779a16f6cbca8a5ffe7f6b0c68572819723. --- pym/_emerge/SubProcess.py | 36 +++++++----------------------------- 1 files changed, 7 insertions(+), 29 deletions(-) diff --git a/pym/_emerge/SubProcess.py b/pym/_emerge/SubProcess.py index 01004a8..9c033c5 100644 --- a/pym/_emerge/SubProcess.py +++ b/pym/_emerge/SubProcess.py @@ -20,9 +20,6 @@ class SubProcess(AbstractPollTask): # we've sent a kill signal to our subprocess. _cancel_timeout =3D 1000 # 1 second =20 - # Poll interval for process exit status. - _waitpid_interval =3D 1000 # 1 second - def _poll(self): if self.returncode is not None: return self.returncode @@ -95,37 +92,18 @@ class SubProcess(AbstractPollTask): return self.returncode =20 def _waitpid_loop(self): - if not self._waitpid_cb(): - return - - timeout_id =3D self.scheduler.timeout_add( - self._waitpid_interval, self._waitpid_cb) + source_id =3D self.scheduler.child_watch_add( + self.pid, self._waitpid_cb) try: while self.returncode is None: self.scheduler.iteration() finally: - self.scheduler.source_remove(timeout_id) - - def _waitpid_cb(self): - if self.returncode is not None: - return False - try: - # With waitpid and WNOHANG, only check the - # first element of the tuple since the second - # element may vary (bug #337465). - wait_retval =3D os.waitpid(self.pid, os.WNOHANG) - except OSError as e: - if e.errno !=3D errno.ECHILD: - raise - del e - self._set_returncode((self.pid, 1 << 8)) - return False - else: - if wait_retval[0] !=3D 0: - self._set_returncode(wait_retval) - return False + self.scheduler.source_remove(source_id) =20 - return True + def _waitpid_cb(self, pid, condition, user_data): + if pid !=3D self.pid: + raise AssertionError("expected pid %s, got %s" % (self.pid, pid)) + self._set_returncode((pid, condition)) =20 def _orphan_process_warn(self): pass