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 1Rv0iM-0000Q2-SH for garchives@archives.gentoo.org; Wed, 08 Feb 2012 06:09:11 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5C56DE07D5; Wed, 8 Feb 2012 06:09:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 27940E0802 for ; Wed, 8 Feb 2012 06:09:03 +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 9AB211B4034 for ; Wed, 8 Feb 2012 06:09:02 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 100418004F for ; Wed, 8 Feb 2012 06:09:02 +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: <7e38a0253bdc1a25b54f0783c0bb2a72239fdb05.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/AbstractPollTask.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 7e38a0253bdc1a25b54f0783c0bb2a72239fdb05 Date: Wed, 8 Feb 2012 06:09:02 +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: e48f6c05-fb90-4267-aeca-15b55f486d9c X-Archives-Hash: 556d30daaf50102a260552b03e5e34de commit: 7e38a0253bdc1a25b54f0783c0bb2a72239fdb05 Author: Zac Medico gentoo org> AuthorDate: Wed Feb 8 05:16:51 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Feb 8 06:08:45 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D7e38a025 AbstractPollTask: use timeout_add --- pym/_emerge/AbstractPollTask.py | 25 +++++++++++-------------- 1 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pym/_emerge/AbstractPollTask.py b/pym/_emerge/AbstractPollTa= sk.py index b4728e7..9229052 100644 --- a/pym/_emerge/AbstractPollTask.py +++ b/pym/_emerge/AbstractPollTask.py @@ -5,7 +5,6 @@ import array import errno import logging import os -import time =20 from portage.util import writemsg_level from _emerge.AsynchronousTask import AsynchronousTask @@ -129,16 +128,14 @@ class AbstractPollTask(AsynchronousTask): self.scheduler.iteration() return =20 - remaining_timeout =3D timeout - start_time =3D time.time() - while self._registered: - self.scheduler.iteration() - 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. - break - remaining_timeout =3D timeout - 1000 * elapsed_time - if remaining_timeout <=3D 0: - break + def timeout_cb(): + timeout_cb.timed_out =3D True + return False + timeout_cb.timed_out =3D False + timeout_cb.timeout_id =3D self.scheduler.timeout_add(timeout, timeout_= cb) + + try: + while self._registered and not timeout_cb.timed_out: + self.scheduler.iteration() + finally: + self.scheduler.unregister(timeout_cb.timeout_id)