From 00a5523d340662b31b27f12a004cb5ae0a4bab6f Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Thu, 22 Sep 2005 15:53:36 +0000 Subject: [PATCH] Change package.py to access a single global portage.config object. Fixes bug #90680 svn path=/; revision=238 --- trunk/src/gentoolkit/__init__.py | 2 ++ trunk/src/gentoolkit/package.py | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/trunk/src/gentoolkit/__init__.py b/trunk/src/gentoolkit/__init__.py index 56f3e92..eb103ad 100644 --- a/trunk/src/gentoolkit/__init__.py +++ b/trunk/src/gentoolkit/__init__.py @@ -24,7 +24,9 @@ import portage import re import string import types +from threading import Lock +settingslock = Lock() settings = portage.config(clone=portage.settings) porttree = portage.db[portage.root]["porttree"] vartree = portage.db[portage.root]["vartree"] diff --git a/trunk/src/gentoolkit/package.py b/trunk/src/gentoolkit/package.py index 689145f..e1d0a0d 100644 --- a/trunk/src/gentoolkit/package.py +++ b/trunk/src/gentoolkit/package.py @@ -23,8 +23,8 @@ class Package: if not self._scpv: raise FatalError("invalid cpv: %s" % cpv) self._db = None - settings.setcpv(self._cpv) - self._settings = portage.config(clone=settings) + self._settings = settings + self._settingslock = settingslock def get_name(self): """Returns base name of package, no category nor version""" @@ -44,7 +44,11 @@ class Package: def get_settings(self, key): """Returns the value of the given key for this package (useful for package.* files.""" - return self._settings[key] + self._settingslock.acquire() + self._settings.setcpv(self._cpv) + v = self._settings[key] + self._settingslock.release() + return v def get_cpv(self): """Returns full Category/Package-Version string""" -- 2.26.2