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 1Ruz68-0000u1-L4 for garchives@archives.gentoo.org; Wed, 08 Feb 2012 04:25:36 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 54DD9E05FE; Wed, 8 Feb 2012 04:25:29 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 20F00E05FE for ; Wed, 8 Feb 2012 04:25:29 +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 9ABFF1B4013 for ; Wed, 8 Feb 2012 04:25:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id D7B2680043 for ; Wed, 8 Feb 2012 04:25:27 +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: <20a5f9cb0c9fec433df7256617bd8fe09892fafa.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/QueueScheduler.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 20a5f9cb0c9fec433df7256617bd8fe09892fafa Date: Wed, 8 Feb 2012 04:25:27 +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: 6667e5db-344b-4ffe-a5f8-42d84c0eca89 X-Archives-Hash: afaae81a2cb8f0762201cad17ebbe503 commit: 20a5f9cb0c9fec433df7256617bd8fe09892fafa Author: Zac Medico gentoo org> AuthorDate: Wed Feb 8 04:24:47 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Feb 8 04:24:47 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D20a5f9cb QueueScheduler: use timeout_add --- pym/_emerge/QueueScheduler.py | 51 +++++++++++++----------------------= ----- 1 files changed, 17 insertions(+), 34 deletions(-) diff --git a/pym/_emerge/QueueScheduler.py b/pym/_emerge/QueueScheduler.p= y index a4ab328..91a2831 100644 --- a/pym/_emerge/QueueScheduler.py +++ b/pym/_emerge/QueueScheduler.py @@ -36,42 +36,25 @@ class QueueScheduler(PollScheduler): =20 def run(self, timeout=3DNone): =20 - start_time =3D None - timed_out =3D False - remaining_timeout =3D timeout + timeout_id =3D None if timeout is not None: - start_time =3D time.time() - - while self._schedule(): - self._schedule_wait(timeout=3Dremaining_timeout) - if timeout is not None: - elapsed_time =3D time.time() - start_time - if elapsed_time < 0: - # The system clock has changed such that start_time - # is now in the future, so just assume that the - # timeout has already elapsed. - timed_out =3D True - break - remaining_timeout =3D timeout - 1000 * elapsed_time - if remaining_timeout <=3D 0: - timed_out =3D True - break - - if timeout is None or not timed_out: + def timeout_callback(): + raise StopIteration() + timeout_id =3D self._timeout_add(timeout, timeout_callback) + + try: + + while self._schedule(): + self._iteration() + while self._running_job_count(): - self._schedule_wait(timeout=3Dremaining_timeout) - if timeout is not None: - elapsed_time =3D time.time() - start_time - if elapsed_time < 0: - # The system clock has changed such that start_time - # is now in the future, so just assume that the - # timeout has already elapsed. - timed_out =3D True - break - remaining_timeout =3D timeout - 1000 * elapsed_time - if remaining_timeout <=3D 0: - timed_out =3D True - break + self._iteration() + + except StopIteration: + pass + + if timeout_id is not None: + self._unregister(timeout_id) =20 def _schedule_tasks(self): """