]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add debug logging to contextutil.nested.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 16 Jun 2011 17:37:11 +0000 (10:37 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Thu, 16 Jun 2011 17:39:26 +0000 (10:39 -0700)
teuthology/contextutil.py

index 296d889690a4dd4e56d6f1a1cf1f4f8fb7ff02f5..690d07f951099a81f7ddeb03c7e3b3f969faee96 100644 (file)
@@ -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: