From 7c7fb6e830e75b48acc061e77bed34a40d8de6e8 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 5 Jan 2011 17:41:28 -0800 Subject: [PATCH] Scheduler: cache Package instance more This helps to avoid some cases in which emerge crashes due to ebuild modification that leads to failure in aux_get/manifest check while the Scheduler is running. Typically such modifications are harmless, so it's beneficial to cache the metadata so that aux_get is less likely to be called when it will fail. --- pym/_emerge/Scheduler.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index e30646fa9..d30abc405 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -433,12 +433,14 @@ class Scheduler(PollScheduler): if graph_config is None: self._graph_config = None + self._pkg_cache = {} self._digraph = None self._mergelist = [] self._deep_system_deps.clear() return self._graph_config = graph_config + self._pkg_cache = graph_config.pkg_cache self._digraph = graph_config.graph self._mergelist = graph_config.mergelist @@ -2003,18 +2005,19 @@ class Scheduler(PollScheduler): if installed: operation = "nomerge" - if self._graph_config is not None: - # Reuse existing instance when available. - pkg = self._graph_config.pkg_cache.get( - (type_name, root_config.root, cpv, operation, repo_key)) - if pkg is not None: - return pkg + # Reuse existing instance when available. + pkg = self._pkg_cache.get( + (type_name, root_config.root, cpv, operation, repo_key)) + if pkg is not None: + return pkg tree_type = depgraph.pkg_tree_map[type_name] db = root_config.trees[tree_type].dbapi db_keys = list(self.trees[root_config.root][ tree_type].dbapi._aux_cache_keys) metadata = zip(db_keys, db.aux_get(cpv, db_keys, myrepo=myrepo)) - return Package(built=(type_name != 'ebuild'), - cpv=cpv, metadata=metadata, - root_config=root_config, installed=installed) + pkg = Package(built=(type_name != "ebuild"), + cpv=cpv, installed=installed, metadata=metadata, + root_config=root_config, type_name=type_name) + self._pkg_cache[pkg] = pkg + return pkg -- 2.26.2