summaryrefslogtreecommitdiffstats
path: root/src/lib/Component.py
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-05-03 14:05:07 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-05-03 14:05:07 -0500
commit71a026b3b7c13fdf242d387b255d6e0daefce0ca (patch)
tree2decb82d93bdd67365162ddfcbb472caffdbbd06 /src/lib/Component.py
parent1f5b1dd445ca673e26c1a5723fa820726aa48094 (diff)
downloadbcfg2-71a026b3b7c13fdf242d387b255d6e0daefce0ca.tar.gz
bcfg2-71a026b3b7c13fdf242d387b255d6e0daefce0ca.tar.bz2
bcfg2-71a026b3b7c13fdf242d387b255d6e0daefce0ca.zip
Common: Fixes to get server to start with PY3K
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Component.py')
-rw-r--r--src/lib/Component.py47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/lib/Component.py b/src/lib/Component.py
index 222a856d6..88dce906e 100644
--- a/src/lib/Component.py
+++ b/src/lib/Component.py
@@ -153,30 +153,31 @@ class Component (object):
automatic == True.
"""
- for name, func in inspect.getmembers(self, callable):
- if getattr(func, "automatic", False):
- need_to_lock = not getattr(func, 'locking', False)
- if (time.time() - func.automatic_ts) > \
- func.automatic_period:
- if need_to_lock:
- t1 = time.time()
- self.lock.acquire()
- t2 = time.time()
- self.instance_statistics.add_value('component_lock', t2-t1)
- try:
- mt1 = time.time()
+ for name, func in inspect.getmembers(self):
+ if name == '__call__':
+ if getattr(func, "automatic", False):
+ need_to_lock = not getattr(func, 'locking', False)
+ if (time.time() - func.automatic_ts) > \
+ func.automatic_period:
+ if need_to_lock:
+ t1 = time.time()
+ self.lock.acquire()
+ t2 = time.time()
+ self.instance_statistics.add_value('component_lock', t2-t1)
try:
- func()
- except:
- self.logger.error("Automatic method %s failed" \
- % (name), exc_info=1)
- finally:
- mt2 = time.time()
-
- if need_to_lock:
- self.lock.release()
- self.instance_statistics.add_value(name, mt2-mt1)
- func.__dict__['automatic_ts'] = time.time()
+ mt1 = time.time()
+ try:
+ func()
+ except:
+ self.logger.error("Automatic method %s failed" \
+ % (name), exc_info=1)
+ finally:
+ mt2 = time.time()
+
+ if need_to_lock:
+ self.lock.release()
+ self.instance_statistics.add_value(name, mt2-mt1)
+ func.__dict__['automatic_ts'] = time.time()
def _resolve_exposed_method(self, method_name):
"""Resolve an exposed method.