From 8192978cc3a38959a94a63f40f1e4585beb674e2 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Sun, 6 Jan 2013 12:50:28 -0800 Subject: [PATCH] MetadataRegen: call cp_all for each category List categories individually, in order to start yielding quicker, and in order to reduce latency in case of a signal interrupt. --- pym/_emerge/MetadataRegen.py | 20 ++++++++++--------- .../_parallel_manifest/ManifestScheduler.py | 17 +++++++++------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pym/_emerge/MetadataRegen.py b/pym/_emerge/MetadataRegen.py index 8dc7ebeee..213fc3df9 100644 --- a/pym/_emerge/MetadataRegen.py +++ b/pym/_emerge/MetadataRegen.py @@ -33,15 +33,16 @@ class MetadataRegen(AsyncScheduler): return next(self._process_iter) def _iter_every_cp(self): - portage.writemsg_stdout("Listing available packages...\n") - every_cp = self._portdb.cp_all() - portage.writemsg_stdout("Regenerating cache entries...\n") - every_cp.reverse() - try: - while not self._terminated_tasks: - yield every_cp.pop() - except IndexError: - pass + # List categories individually, in order to start yielding quicker, + # and in order to reduce latency in case of a signal interrupt. + categories = sorted(self._portdb.settings.categories, reverse=True) + cp_all = self._portdb.cp_all + + while categories: + category = categories.pop() + category_cps = cp_all(categories=(category,), reverse=True) + while category_cps: + yield category_cps.pop() def _iter_metadata_processes(self): portdb = self._portdb @@ -49,6 +50,7 @@ class MetadataRegen(AsyncScheduler): cp_set = self._cp_set consumer = self._consumer + portage.writemsg_stdout("Regenerating cache entries...\n") for cp in self._cp_iter: if self._terminated.is_set(): break diff --git a/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py b/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py index 50c9c7404..8839989a1 100644 --- a/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py +++ b/pym/portage/package/ebuild/_parallel_manifest/ManifestScheduler.py @@ -30,13 +30,16 @@ class ManifestScheduler(AsyncScheduler): return next(self._task_iter) def _iter_every_cp(self): - every_cp = self._portdb.cp_all() - every_cp.reverse() - try: - while not self._terminated_tasks: - yield every_cp.pop() - except IndexError: - pass + # List categories individually, in order to start yielding quicker, + # and in order to reduce latency in case of a signal interrupt. + categories = sorted(self._portdb.settings.categories, reverse=True) + cp_all = self._portdb.cp_all + + while categories: + category = categories.pop() + category_cps = cp_all(categories=(category,), reverse=True) + while category_cps: + yield category_cps.pop() def _iter_tasks(self): portdb = self._portdb -- 2.26.2