Avoid recreating notify details for each dispatch iteration

We can just create the notification details once and reuse
it for each iteration, instead of recreating it for each
iteration; saves some resources...

Change-Id: Ie8ad61647afe2eef813af87a915710cf91de8e46
This commit is contained in:
Joshua Harlow
2015-11-16 15:45:12 -08:00
committed by Thomas Goirand
parent 99b0eb2f42
commit 989aafb160

View File

@@ -172,22 +172,19 @@ class ExecutorConductor(base.Conductor):
stack.enter_context(listener)
self._log.debug("Dispatching engine for job '%s'", job)
consume = True
details = {
'job': job,
'engine': engine,
'conductor': self,
}
try:
for stage_func, event_name in [(engine.compile, 'compilation'),
(engine.prepare, 'preparation'),
(engine.validate, 'validation'),
(engine.run, 'running')]:
self._notifier.notify("%s_start" % event_name, {
'job': job,
'engine': engine,
'conductor': self,
})
self._notifier.notify("%s_start" % event_name, details)
stage_func()
self._notifier.notify("%s_end" % event_name, {
'job': job,
'engine': engine,
'conductor': self,
})
self._notifier.notify("%s_end" % event_name, details)
except excp.WrappedFailure as e:
if all((f.check(*self.NO_CONSUME_EXCEPTIONS) for f in e)):
consume = False