def safe_redis(return_type):
    def decorator(f):
        @functools.wraps(f)
        def wrapper(*args, **kw):
            try:
                return f(*args, **kw)
            except (socket.error, redislib.RedisError) as e:
                log.error('redis error: %s' % e)
                # log.error('%r\n%r : %r' % (f.__name__, args[1:], kw))
                if hasattr(return_type, '__call__'):
                    return return_type()
                else:
                    return return_type
        return wrapper
    return decorator
Configure parser for this action
dataset/ETHPy150Open django-cache-machine/django-cache-machine/caching/invalidation.py/safe_redis--crossover with--dataset/ETHPy150Open aldebaran/qibuild/python/qibuild/actions/make_host_tools.py/configure_parser