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 1RvLFZ-00069m-O0 for garchives@archives.gentoo.org; Thu, 09 Feb 2012 04:04:49 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B4294E0593; Thu, 9 Feb 2012 04:04:42 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 75420E0593 for ; Thu, 9 Feb 2012 04:04:42 +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 846371B402B for ; Thu, 9 Feb 2012 04:04:41 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 3A711E53FF for ; Thu, 9 Feb 2012 04:04:40 +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: <6823977b783a7205154af5f4234fe02982c62666.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/MetadataRegen.py pym/_emerge/PollScheduler.py pym/_emerge/Scheduler.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 6823977b783a7205154af5f4234fe02982c62666 Date: Thu, 9 Feb 2012 04:04:40 +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: 5ead96b8-966f-4b8e-810a-c1ee752dffae X-Archives-Hash: 62abf9e00cbc59176232735863c5ff90 commit: 6823977b783a7205154af5f4234fe02982c62666 Author: Zac Medico gentoo org> AuthorDate: Thu Feb 9 04:04:09 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Thu Feb 9 04:04:09 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D6823977b PollScheduler: remove _poll_loop We can use iteration() instead, and _poll_loop's exit behavior doesn't seem practical to emulate with glib.MainLoop. --- pym/_emerge/MetadataRegen.py | 9 ++++++--- pym/_emerge/PollScheduler.py | 24 ++---------------------- pym/_emerge/Scheduler.py | 13 +++++-------- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py index 07fd397..1ebc532 100644 --- a/pym/_emerge/MetadataRegen.py +++ b/pym/_emerge/MetadataRegen.py @@ -33,6 +33,7 @@ class MetadataRegen(PollScheduler): self.returncode =3D os.EX_OK self._error_count =3D 0 self._running_tasks =3D set() + self._remaining_tasks =3D True =20 def _terminate_tasks(self): while self._running_tasks: @@ -87,11 +88,12 @@ class MetadataRegen(PollScheduler): from portage.cache.cache_errors import CacheError dead_nodes =3D {} =20 - while self._schedule(): - self.sched_iface.run() + self._schedule() + while self._remaining_tasks and not self._terminated_tasks: + self.sched_iface.iteration() =20 while self._jobs: - self.sched_iface.run() + self.sched_iface.iteration() =20 if self._terminated_tasks: self.returncode =3D 1 @@ -151,6 +153,7 @@ class MetadataRegen(PollScheduler): try: metadata_process =3D next(self._process_iter) except StopIteration: + self._remaining_tasks =3D False return False =20 self._jobs +=3D 1 diff --git a/pym/_emerge/PollScheduler.py b/pym/_emerge/PollScheduler.py index ab65054..018188b 100644 --- a/pym/_emerge/PollScheduler.py +++ b/pym/_emerge/PollScheduler.py @@ -130,9 +130,8 @@ class EventLoop(object): =20 def _next_poll_event(self, timeout=3DNone): """ - Since the _schedule_wait() loop is called by event - handlers from _poll_loop(), maintain a central event - queue for both of them to share events from a single + Since iteration() can be called recursively, maintain + a central event queue to share events from a single poll() call. In order to avoid endless blocking, this raises StopIteration if timeout is None and there are no file descriptors to poll. @@ -143,24 +142,6 @@ class EventLoop(object): raise StopIteration() return self._poll_event_queue.pop() =20 - def _poll_loop(self): - - event_handlers =3D self._poll_event_handlers - event_handled =3D False - - try: - while event_handlers: - f, event =3D self._next_poll_event() - x =3D event_handlers[f] - if not x.callback(f, event, *x.args): - self.source_remove(x.source_id) - event_handled =3D True - except StopIteration: - event_handled =3D True - - if not event_handled: - raise AssertionError("tight loop") - def iteration(self, *args): """ Like glib.MainContext.iteration(), runs a single iteration. @@ -376,7 +357,6 @@ class PollScheduler(object): iteration=3Dself._event_loop.iteration, output=3Dself._task_output, register=3Dself._event_loop.io_add_watch, - run=3Dself._event_loop._poll_loop, source_remove=3Dself._event_loop.source_remove, timeout_add=3Dself._event_loop.timeout_add, unregister=3Dself._event_loop.source_remove) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 6502f71..12f0871 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -222,7 +222,6 @@ class Scheduler(PollScheduler): io_add_watch=3Dself._event_loop.io_add_watch, iteration=3Dself._event_loop.iteration, register=3Dself._event_loop.io_add_watch, - schedule=3Dself._event_loop._poll_loop, scheduleSetup=3Dself._schedule_setup, scheduleUnpack=3Dself._schedule_unpack, source_remove=3Dself._event_loop.source_remove, @@ -1492,14 +1491,12 @@ class Scheduler(PollScheduler): if self._opts_no_background.intersection(self.myopts): self._set_max_jobs(1) =20 - while self._schedule(): - self.sched_iface.run() + self._schedule() + while self._keep_scheduling(): + self.sched_iface.iteration() =20 - while True: - self._schedule() - if not self._is_work_scheduled(): - break - self.sched_iface.run() + while self._is_work_scheduled(): + self.sched_iface.iteration() =20 def _keep_scheduling(self): return bool(not self._terminated_tasks and self._pkg_queue and \