From 6c8cf8acb7c2bb340803a2940cdeac689848e914 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Fri, 16 Oct 2015 18:01:27 -0400 Subject: [PATCH] now profile_tasks callback handles handlers correctly fixes #12762 --- lib/ansible/plugins/callback/profile_tasks.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/ansible/plugins/callback/profile_tasks.py b/lib/ansible/plugins/callback/profile_tasks.py index 28aec1c7df..4824ef4a87 100644 --- a/lib/ansible/plugins/callback/profile_tasks.py +++ b/lib/ansible/plugins/callback/profile_tasks.py @@ -59,21 +59,20 @@ def tasktime(): class CallbackModule(CallbackBase): """ - This callback module provides per-task timing, ongoing playbook elapsed time + This callback module provides per-task timing, ongoing playbook elapsed time and ordered list of top 20 longest running tasks at end. """ CALLBACK_VERSION = 2.0 CALLBACK_TYPE = 'aggregate' CALLBACK_NAME = 'profile_tasks' - + def __init__(self, display): self.stats = {} self.current = None super(CallbackModule, self).__init__(display) - - def playbook_on_task_start(self, name, is_conditional): + def _record_task(self, name): """ Logs the start of each task """ @@ -84,6 +83,12 @@ class CallbackModule(CallbackBase): self.current = name self.stats[self.current] = time.time() + def playbook_on_task_start(self, name, is_conditional): + self._record_task(name) + + def v2_playbook_on_handler_task_start(self, task): + self._record_task('HANDLER: ' + task.name) + def playbook_on_setup(self): self._display.display(tasktime())