diff options
author | Joshua Harlow <harlowja@gmail.com> | 2015-02-10 22:55:37 -0800 |
---|---|---|
committer | Joshua Harlow <harlowja@gmail.com> | 2015-02-10 22:57:24 -0800 |
commit | 59771ddc6d16468c5e2010ea16f2be552f02a679 (patch) | |
tree | f78d665046d9b6ff702ef99de0f03dc4f5fbfd49 | |
parent | 687ec913790653f79badc8f5d656c86792e94271 (diff) | |
download | taskflow-59771ddc6d16468c5e2010ea16f2be552f02a679.tar.gz |
Let the multi-lock convert the provided value to a tuple
Instead of forcing the locks (list or tuple) into a list
and then having the multi-lock code force that back into
a tuple just pass the value through to the multi-lock
class and let it handle the conversion in a more easy to
understand manner (and one that doesn't involve as many
copies).
Change-Id: Ib0e78bacb80aea73af465a91cb4f509904f47990
-rw-r--r-- | taskflow/utils/lock_utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/taskflow/utils/lock_utils.py b/taskflow/utils/lock_utils.py index 648d6bb..ea2023e 100644 --- a/taskflow/utils/lock_utils.py +++ b/taskflow/utils/lock_utils.py @@ -80,9 +80,11 @@ def locked(*args, **kwargs): @six.wraps(f) def wrapper(self, *args, **kwargs): - lock = getattr(self, attr_name) - if isinstance(lock, (tuple, list)): - lock = MultiLock(locks=list(lock)) + attr_value = getattr(self, attr_name) + if isinstance(attr_value, (tuple, list)): + lock = MultiLock(attr_value) + else: + lock = attr_value with lock: return f(self, *args, **kwargs) |