Exemplo n.º 1
0
 def RedisParser():
     return _RedisParser(InvalidResponse, response_error)
Exemplo n.º 2
0

EXCEPTION_CLASSES = {
    'ERR': ResponseError,
    'NOSCRIPT': NoScriptError,
}


def response_error(response):
    "Parse an error response"
    response = response.split(' ')
    error_code = response[0]
    if error_code not in EXCEPTION_CLASSES:
        error_code = 'ERR'
    response = ' '.join(response[1:])
    return EXCEPTION_CLASSES[error_code](response)


PyRedisParser = lambda: Parser(InvalidResponse, response_error)


if pulsar.HAS_C_EXTENSIONS:
    from pulsar.utils.lib import RedisParser as _RedisParser
    RedisParser = lambda: _RedisParser(InvalidResponse, response_error)
else:
    RedisParser = PyRedisParser


def redis_parser(py_redis_parser=False):
    return PyRedisParser if py_redis_parser else RedisParser
Exemplo n.º 3
0
 def RedisParser():
     return _RedisParser(InvalidResponse, response_error)
Exemplo n.º 4
0
    pass


EXCEPTION_CLASSES = {
    'ERR': ResponseError,
    'NOSCRIPT': NoScriptError,
}


def response_error(response):
    "Parse an error response"
    response = response.split(' ')
    error_code = response[0]
    if error_code not in EXCEPTION_CLASSES:
        error_code = 'ERR'
    response = ' '.join(response[1:])
    return EXCEPTION_CLASSES[error_code](response)


PyRedisParser = lambda: Parser(InvalidResponse, response_error)

if pulsar.HAS_C_EXTENSIONS:
    from pulsar.utils.lib import RedisParser as _RedisParser
    RedisParser = lambda: _RedisParser(InvalidResponse, response_error)
else:  # pragma nocover
    RedisParser = PyRedisParser


def redis_parser(py_redis_parser=False):
    return PyRedisParser if py_redis_parser else RedisParser