From 231f3e138a03a6775bf447264043feac25fb52f0 Mon Sep 17 00:00:00 2001 From: Matt Martz Date: Mon, 18 Mar 2019 10:21:49 -0500 Subject: [PATCH] Close files before opening new ones (#53961) --- lib/ansible/plugins/callback/cgroup_perf_recap.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/ansible/plugins/callback/cgroup_perf_recap.py b/lib/ansible/plugins/callback/cgroup_perf_recap.py index c945301148..2e8b6adbf9 100644 --- a/lib/ansible/plugins/callback/cgroup_perf_recap.py +++ b/lib/ansible/plugins/callback/cgroup_perf_recap.py @@ -364,6 +364,14 @@ class CallbackModule(CallbackBase): def _profile(self, obj=None): prev_task = None results = dict.fromkeys(self._features) + for dummy, f in self._files.items(): + if f is None: + continue + try: + f.close() + except Exception: + pass + try: for name, prof in self._profilers.items(): prof.running = False @@ -397,12 +405,6 @@ class CallbackModule(CallbackBase): def v2_playbook_on_stats(self, stats): self._profile() - for dummy, f in self._files.items(): - try: - f.close() - except Exception: - pass - if not self._display_recap: return