Last active
May 14, 2018 02:36
-
-
Save nooperpudd/7a37bfa6836a176116b092aff1e40d3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _transaction(watch_arg=None, use_pipe=True, ): | |
# """ | |
# wrapper class | |
# :return: | |
# """ | |
# | |
# def wrapper(func): | |
# """ | |
# :return: | |
# """ | |
# | |
# @functools.wraps(func) | |
# def inner(self, *args, **kwargs): | |
# """ | |
# :param self: class instance | |
# :param args: | |
# :param kwargs: | |
# :return: | |
# """ | |
# trans = getattr(self, "transaction") | |
# redis_client = getattr(self, "client", None) | |
# | |
# call_args = inspect.getcallargs(func, **kwargs) | |
# watch_value = call_args.get(watch_arg) | |
# if redis_client and trans: | |
# | |
# result = None | |
# try: | |
# redis_client.watch(watch_value) | |
# result = func(self, *args, **kwargs) | |
# except redis.WatchError: | |
# continue | |
# else: | |
# redis_client.unwatch() | |
# return result | |
# | |
# | |
# else: | |
# return func(self, *args, **kwargs) | |
# | |
# return inner | |
return wrapper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment