summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2011-01-19 11:24:31 -0500
committerSimo Sorce <ssorce@redhat.com>2011-01-28 18:49:17 -0500
commit359d54e741877f04b0773fb0955041eee7ec0054 (patch)
tree8a1c69754da14a502d809330e2f8f7831ff0c16b /ipalib
parentfd1d0857b5b559425668f38d85a7d607d0f35767 (diff)
downloadfreeipa-359d54e741877f04b0773fb0955041eee7ec0054.tar.gz
freeipa-359d54e741877f04b0773fb0955041eee7ec0054.tar.xz
freeipa-359d54e741877f04b0773fb0955041eee7ec0054.zip
Don't perform some API self-tests in production mode for performance reasons
The API does a fair number of self tests and locking to assure that the registered commands are consistent and will work. This does not need to be done on a production system and adds additional overhead causing somewhere between a 30 and 50% decrease in performance. Because makeapi is executed when a build is done ensure that it is executed in developer mode to ensure that the framework is ok. ticket 751
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/config.py3
-rw-r--r--ipalib/frontend.py7
-rw-r--r--ipalib/plugable.py15
3 files changed, 17 insertions, 8 deletions
diff --git a/ipalib/config.py b/ipalib/config.py
index ec86d9e1b..888785a26 100644
--- a/ipalib/config.py
+++ b/ipalib/config.py
@@ -467,6 +467,9 @@ class Env(object):
else:
self.in_tree = False
+ if self.in_tree and 'mode' not in self:
+ self.mode = 'developer'
+
# Set dot_ipa:
if 'dot_ipa' not in self:
self.dot_ipa = self._join('home', '.ipa')
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 58fd4d640..cf78d441f 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -351,9 +351,10 @@ class HasParam(Plugin):
self._filter_param_by_context(name, env),
sort=False
)
- check = getattr(self, 'check_' + name, None)
- if callable(check):
- check(namespace)
+ if self.env.mode != 'production':
+ check = getattr(self, 'check_' + name, None)
+ if callable(check):
+ check(namespace)
setattr(self, name, namespace)
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 264bb68cf..82bd52283 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -207,6 +207,8 @@ class Plugin(ReadOnly):
def finalize(self):
"""
"""
+ if self.env.mode == 'production':
+ return
lock(self)
def set_api(self, api):
@@ -601,19 +603,22 @@ class API(DictProxy):
namespace = NameSpace(
plugin_iter(base, (magic[k] for k in magic))
)
- assert not (
- name in self.__d or hasattr(self, name)
- )
+ if self.env.mode != 'production':
+ assert not (
+ name in self.__d or hasattr(self, name)
+ )
self.__d[name] = namespace
object.__setattr__(self, name, namespace)
for p in plugins.itervalues():
p.instance.set_api(self)
- assert p.instance.api is self
+ if self.env.mode != 'production':
+ assert p.instance.api is self
for p in plugins.itervalues():
p.instance.finalize()
- assert islocked(p.instance) is True
+ if self.env.mode != 'production':
+ assert islocked(p.instance) is True
object.__setattr__(self, '_API__finalized', True)
tuple(PluginInfo(p) for p in plugins.itervalues())
object.__setattr__(self, 'plugins',