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:
@@ -29,8 +29,8 @@ from taskflow.utils import threading_utils
|
|||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def _autobind(task, bind_name, bind_func, **kwargs):
|
def _autobind(task, bind_name, bind_func, **kwargs):
|
||||||
try:
|
|
||||||
task.bind(bind_name, bind_func, **kwargs)
|
task.bind(bind_name, bind_func, **kwargs)
|
||||||
|
try:
|
||||||
yield task
|
yield task
|
||||||
finally:
|
finally:
|
||||||
task.unbind(bind_name, bind_func)
|
task.unbind(bind_name, bind_func)
|
||||||
|
|||||||
Reference in New Issue
Block a user