Fix the timer.

master
Simon Quigley 5 years ago
parent a145c02dde
commit c394b5221b

@ -29,6 +29,7 @@ timer = TimerMetrics()
class Generator: class Generator:
@timer.run("Clone the metadata")
def clone_metadata(self): def clone_metadata(self):
"""Clone the metadata repository using the values set in the env vars """Clone the metadata repository using the values set in the env vars
@ -149,6 +150,7 @@ class Generator:
return server return server
@timer.run("Load configuration files")
def load_config(self, job_type, data=None): def load_config(self, job_type, data=None):
"""Return a template that is a result of loading the data """Return a template that is a result of loading the data
@ -230,6 +232,7 @@ class Generator:
if not name in server.views[view]: if not name in server.views[view]:
view.add_job(name) view.add_job(name)
@timer.run("Master function loop")
def create_jenkins_jobs(self): def create_jenkins_jobs(self):
"""Interface with Jenkins to create the jobs required """Interface with Jenkins to create the jobs required

@ -107,12 +107,24 @@ class TimerMetrics:
""" """
self.start(label) self.start(label)
# Pause all other timers
paused = []
for timer in self.data:
if not timer == label and self.data[timer]["running"]:
self.stop(timer)
paused.append(timer)
def wrap(func): def wrap(func):
def run_function(*args, **kwargs): def run_function(*args, **kwargs):
try: try:
return func(*args, **kwargs) return func(*args, **kwargs)
finally: finally:
self.stop(label) self.stop(label)
# Unpause other timers
for timer in paused:
self.start(timer)
return run_function return run_function
return wrap return wrap

Loading…
Cancel
Save