From: Zack Cerza Date: Tue, 28 Apr 2015 19:26:27 +0000 (-0600) Subject: Run context manager exit if enter fails X-Git-Tag: 1.1.0~946^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=001afeef227411983e83d9854738fd99d3e400c0;p=teuthology.git Run context manager exit if enter fails In run_tasks(), we were waiting until a context manager's __enter__() finished before adding it to the stack. As a result, if __enter__() failed, __exit__() would never be called. Signed-off-by: Zack Cerza --- diff --git a/teuthology/run_tasks.py b/teuthology/run_tasks.py index efeab0757c..cdc5501c08 100644 --- a/teuthology/run_tasks.py +++ b/teuthology/run_tasks.py @@ -52,8 +52,8 @@ def run_tasks(tasks, ctx): log.info('Running task %s...', taskname) manager = run_one_task(taskname, ctx=ctx, config=config) if hasattr(manager, '__enter__'): - manager.__enter__() stack.append((taskname, manager)) + manager.__enter__() except BaseException as e: if isinstance(e, ConnectionLostError): # Prevent connection issues being flagged as failures