Fix the timer.

This commit is contained in:
Simon Quigley 2020-06-05 13:47:12 -05:00
parent a145c02dde
commit c394b5221b
2 changed files with 15 additions and 0 deletions

View File

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

View File

@ -107,12 +107,24 @@ class TimerMetrics:
"""
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 run_function(*args, **kwargs):
try:
return func(*args, **kwargs)
finally:
self.stop(label)
# Unpause other timers
for timer in paused:
self.start(timer)
return run_function
return wrap