Change package.py to access a single global portage.config object. Fixes bug #90680
authorfuzzyray <fuzzyray@gentoo.org>
Thu, 22 Sep 2005 15:53:36 +0000 (15:53 -0000)
committerfuzzyray <fuzzyray@gentoo.org>
Thu, 22 Sep 2005 15:53:36 +0000 (15:53 -0000)
svn path=/; revision=238

trunk/src/gentoolkit/__init__.py
trunk/src/gentoolkit/package.py

index 56f3e9225088159c67b63b0bfb5fc4d0e1568d8b..eb103ad29cf8bf79060d3673c4f4b04152be8213 100644 (file)
@@ -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"]
index 689145fe9419717ad89d51102dd55498d96f8caa..e1d0a0ddb8a6aaf0978af3256cb63aa1f06bf74a 100644 (file)
@@ -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"""