summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/GroupLogic.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-09-27 06:40:04 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-09-27 06:40:04 -0400
commit36641e89d28aeb411cc1886a7ecd90b8bcbf0f8f (patch)
tree359d91fc17bf001c8d53ee831ee6f6a34f4db31b /src/lib/Bcfg2/Server/Plugins/GroupLogic.py
parent5eb0b282d4e5142e37018d12b4a11cae71c82e40 (diff)
downloadbcfg2-36641e89d28aeb411cc1886a7ecd90b8bcbf0f8f.tar.gz
bcfg2-36641e89d28aeb411cc1886a7ecd90b8bcbf0f8f.tar.bz2
bcfg2-36641e89d28aeb411cc1886a7ecd90b8bcbf0f8f.zip
GroupLogic: fixed thread-local variable initialization
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/GroupLogic.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/GroupLogic.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/GroupLogic.py b/src/lib/Bcfg2/Server/Plugins/GroupLogic.py
index aa71d2cfe..d74c16e8b 100644
--- a/src/lib/Bcfg2/Server/Plugins/GroupLogic.py
+++ b/src/lib/Bcfg2/Server/Plugins/GroupLogic.py
@@ -47,19 +47,21 @@ class GroupLogic(Bcfg2.Server.Plugin.Plugin,
self.config = GroupLogicConfig(os.path.join(self.data, "groups.xml"),
core.fam)
self._local = local()
- # building is a thread-local set that tracks which machines
- # GroupLogic is getting additional groups for. If a
- # get_additional_groups() is called twice for a machine before
- # the first call has completed, the second call returns an
- # empty list. This is for infinite recursion protection;
- # without this check, it'd be impossible to use things like
- # metadata.query.in_group() in GroupLogic, since that requires
- # building all metadata, which requires running
- # GroupLogic.get_additional_groups() for all hosts, which
- # requires building all metadata...
- self._local.building = set()
def get_additional_groups(self, metadata):
+ if not hasattr(self._local, "building"):
+ # building is a thread-local set that tracks which
+ # machines GroupLogic is getting additional groups for.
+ # If a get_additional_groups() is called twice for a
+ # machine before the first call has completed, the second
+ # call returns an empty list. This is for infinite
+ # recursion protection; without this check, it'd be
+ # impossible to use things like metadata.query.in_group()
+ # in GroupLogic, since that requires building all
+ # metadata, which requires running
+ # GroupLogic.get_additional_groups() for all hosts, which
+ # requires building all metadata...
+ self._local.building = set()
if metadata.hostname in self._local.building:
return []
self._local.building.add(metadata.hostname)