Bind outside of the try block

If binding fails, we don't want to unbind
since there will be nothing bound, so do
the binding outside of the try/except
block to do this in the correct order.

Change-Id: Iebd3ea7a04265264043c47d4e943778538e8a153
This commit is contained in:
Joshua Harlow
2013-12-26 18:05:21 -08:00
parent 9632fe6392
commit 2538c4810a

View File

@@ -29,8 +29,8 @@ from taskflow.utils import threading_utils
@contextlib.contextmanager
def _autobind(task, bind_name, bind_func, **kwargs):
task.bind(bind_name, bind_func, **kwargs)
try:
task.bind(bind_name, bind_func, **kwargs)
yield task
finally:
task.unbind(bind_name, bind_func)