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 1Ruzu2-0000mB-Mc for garchives@archives.gentoo.org; Wed, 08 Feb 2012 05:17:10 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AFF72E0763; Wed, 8 Feb 2012 05:17:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 822D1E0763 for ; Wed, 8 Feb 2012 05:17: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 09E5C1B4013 for ; Wed, 8 Feb 2012 05:17:03 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 54F6D80052 for ; Wed, 8 Feb 2012 05:17: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: <6b985978952fce6f1bb0741d8657d08a20c9937f.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: 6b985978952fce6f1bb0741d8657d08a20c9937f Date: Wed, 8 Feb 2012 05:17: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: 0521e88c-5d2e-4aa2-8053-d530078dd777 X-Archives-Hash: cee4f5ff51da6c694af645e61722fe5d commit: 6b985978952fce6f1bb0741d8657d08a20c9937f Author: Zac Medico gentoo org> AuthorDate: Wed Feb 8 05:16:51 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Wed Feb 8 05:16:51 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D6b985978 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)