From eaba08fbf4918f222904fffd82e79203987f1e27 Mon Sep 17 00:00:00 2001 From: Tommi Virtanen Date: Thu, 16 Jun 2011 10:37:11 -0700 Subject: [PATCH] Add debug logging to contextutil.nested. --- teuthology/contextutil.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/teuthology/contextutil.py b/teuthology/contextutil.py index 296d889690a..690d07f9510 100644 --- a/teuthology/contextutil.py +++ b/teuthology/contextutil.py @@ -1,5 +1,8 @@ import contextlib import sys +import logging + +log = logging.getLogger(__name__) @contextlib.contextmanager def nested(*managers): @@ -7,6 +10,9 @@ def nested(*managers): Like contextlib.nested but takes callables returning context managers, to avoid the major reason why contextlib.nested was deprecated. + + This version also logs any exceptions early, much like run_tasks, + to ease debugging. TODO combine nested and run_tasks. """ exits = [] vars = [] @@ -20,6 +26,7 @@ def nested(*managers): exits.append(exit) yield vars except: + log.exception('Saw exception from nested tasks') exc = sys.exc_info() finally: while exits: -- 2.47.3