当前位置: 首页>>代码示例>>Python>>正文


Python redis.ResponseError方法代码示例

本文整理汇总了Python中redis.ResponseError方法的典型用法代码示例。如果您正苦于以下问题:Python redis.ResponseError方法的具体用法?Python redis.ResponseError怎么用?Python redis.ResponseError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis的用法示例。


在下文中一共展示了redis.ResponseError方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _SetClientName

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def _SetClientName(cls, redis_client, name):
    """Attempts to sets a Redis client name.

    This method ignores errors from the Redis server or exceptions
    indicating the method is missing, as setting the name is not a critical
    function, and it is not currently supported by the fakeredis test library.

    Args:
      redis_client (Redis): an open Redis client.
      name (str): name to set.
    """
    try:
      redis_client.client_setname(name)
    except redis.ResponseError as exception:
      logger.debug(
          'Unable to set redis client name: {0:s} with error: {1!s}'.format(
              name, exception)) 
开发者ID:log2timeline,项目名称:plaso,代码行数:19,代码来源:redis_store.py

示例2: testCFAddInsert

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def testCFAddInsert(self):
        self.assertTrue(rb.cfCreate('cuckoo', 1000))
        self.assertTrue(rb.cfAdd('cuckoo', 'filter'))
        self.assertFalse(rb.cfAddNX('cuckoo', 'filter'))
        self.assertEqual(1, rb.cfAddNX('cuckoo', 'newItem'))
        self.assertEqual([1], rb.cfInsert('captest', ['foo']))
        self.assertEqual([1], rb.cfInsert('captest', ['foo'], capacity=1000))
        self.assertEqual([1], rb.cfInsertNX('captest', ['bar']))
        self.assertEqual([1], rb.cfInsertNX('captest', ['food'], nocreate='1'))
        self.assertEqual([0, 0, 1], rb.cfInsertNX('captest', ['foo', 'bar', 'baz']))
        self.assertEqual([0], rb.cfInsertNX('captest', ['bar'], capacity=1000))
        self.assertEqual([1], rb.cfInsert('empty1', ['foo'], capacity=1000))
        self.assertEqual([1], rb.cfInsertNX('empty2', ['bar'], capacity=1000))
        self.assertRaises(ResponseError, run_func(rb.cfInsert, 'noexist', ['foo']))
        info = rb.cfInfo('captest')
        self.assertEqual(5, info.insertedNum)
        self.assertEqual(0, info.deletedNum)
        self.assertEqual(1, info.filterNum) 
开发者ID:RedisBloom,项目名称:redisbloom-py,代码行数:20,代码来源:test_commands.py

示例3: migrate

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def migrate(ctx, args):
    src = ClusterNode.from_uri(args.src)
    cluster = Cluster.from_node(src)

    if args.dst:
        dst = ClusterNode.from_uri(args.dst)

    if args.dst and args.slot is not None:
        try:
            cluster.migrate_slot(src, dst, args.slot, verbose=True)
        except redis.ResponseError as e:
            ctx.abort(str(e))
    elif args.dst:
        count = len(src.slots) if args.count is None else args.count
        cluster.migrate(src, dst, count)
    else:
        cluster.migrate_node(src, args.count, income=args.income)

    cluster.wait() 
开发者ID:eleme,项目名称:ruskit,代码行数:21,代码来源:manage.py

示例4: testNoCreate

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def testNoCreate(self):
        client = self.getCleanClient('idx')
        client.create_index((TextField('f1'), TextField('f2'), TextField('f3')))

        client.add_document('doc1', f1='f1_val', f2='f2_val')
        client.add_document('doc2', f1='f1_val', f2='f2_val')

        client.add_document('doc1', f3='f3_val', no_create=True)
        client.add_document('doc2', f3='f3_val', no_create=True, partial=True)

        for i in self.retry_with_reload():
            # Search for f3 value. All documents should have it
            res = client.search('@f3:f3_val')
            self.assertEqual(2, res.total)

            # Only the document updated with PARTIAL should still have the f1 and f2
            # values
            res = client.search('@f3:f3_val @f2:f2_val @f1:f1_val')
            self.assertEqual(1, res.total)            
            
        with self.assertRaises(redis.ResponseError) as error:
            client.add_document('doc3', f2='f2_val', f3='f3_val', no_create=True) 
开发者ID:RediSearch,项目名称:redisearch-py,代码行数:24,代码来源:test.py

示例5: incr

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def incr(self, key, delta=1, version=None):
        """
        Add delta to value in the cache. If the key does not exist, raise a
        ValueError exception.
        """
        key = self.make_key(key, version=version)
        exists = self._client.exists(key)
        if not exists:
            raise ValueError("Key '%s' not found" % key)
        try:
            value = self._client.incr(key, delta)
        except redis.ResponseError:
            value = self.get(key) + delta
            self.set(key, value)
        return value 
开发者ID:mqingyn,项目名称:torngas,代码行数:17,代码来源:rediscache.py

示例6: test_execute_pipeline_2

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def test_execute_pipeline_2(self):
        p = self.conn.pipeline()
        p.set('x', 1)
        # Test that invalid operation halts pipeline.
        p.lrange('x', 0, -1)
        p.set('y', 1)
        pytest.raises(redis.ResponseError, self.scripts.execute_pipeline, p)
        assert self.conn.get('x') == '1'
        assert self.conn.get('y') is None 
开发者ID:closeio,项目名称:tasktiger,代码行数:11,代码来源:test_redis_scripts.py

示例7: __init__

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def __init__(self, graph, response):
        self.graph = graph
        self.header = []
        self.result_set = []

        # If we encountered a run-time error, the last response element will be an exception.
        if isinstance(response[-1], ResponseError):
            raise response[-1]

        if len(response) is 1:
            self.parse_statistics(response[0])
        else:
            self.parse_results(response)
            self.parse_statistics(response[-1])  # Last element. 
开发者ID:RedisGraph,项目名称:redisgraph-py,代码行数:16,代码来源:query_result.py

示例8: replicate

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def replicate(ctx, args):
    """Make node to be the slave of a master.
    """
    slave = ClusterNode.from_uri(args.node)
    master = ClusterNode.from_uri(args.master)
    if not master.is_master():
        ctx.abort("Node {!r} is not a master.".format(args.master))

    try:
        slave.replicate(master.name)
    except redis.ResponseError as e:
        ctx.abort(str(e))

    Cluster.from_node(master).wait() 
开发者ID:eleme,项目名称:ruskit,代码行数:16,代码来源:manage.py

示例9: createIndex

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def createIndex(self, client, num_docs = 100):

        assert isinstance(client, Client)
        #conn.flushdb()
        #client = Client('test', port=conn.port)
        try:
            client.create_index((TextField('play', weight=5.0), 
                                TextField('txt'), 
                                NumericField('chapter')))
        except redis.ResponseError:
            client.drop_index()
            return self.createIndex(client, num_docs=num_docs)

        chapters = {}
        bzfp = bz2.BZ2File(WILL_PLAY_TEXT)
        if six.PY3:
            bzfp = TextIOWrapper(bz2.BZ2File(WILL_PLAY_TEXT), encoding='utf8')

        r = csv.reader(bzfp, delimiter=';')
        for n, line in enumerate(r):
            #['62816', 'Merchant of Venice', '9', '3.2.74', 'PORTIA', "I'll begin it,--Ding, dong, bell."]

            play, chapter, character, text = line[1], line[2], line[4], line[5]

            key = '{}:{}'.format(play, chapter).lower()
            d = chapters.setdefault(key, {})
            d['play'] = play
            d['txt'] = d.get('txt', '') + ' ' + text
            d['chapter'] = int(chapter or 0)
            if len(chapters) == num_docs:
                break

        indexer = client.batch_indexer(chunk_size=50)
        self.assertIsInstance(indexer, Client.BatchIndexer)
        self.assertEqual(50, indexer.chunk_size)

        for key, doc in six.iteritems(chapters):
            indexer.add_document(key, **doc)
        indexer.commit() 
开发者ID:RediSearch,项目名称:redisearch-py,代码行数:41,代码来源:test.py

示例10: _raise_on_error

# 需要导入模块: import redis [as 别名]
# 或者: from redis import ResponseError [as 别名]
def _raise_on_error(func):
        @functools.wraps(func)
        def wrap(*args, **kwargs):
            try:
                return func(*args, **kwargs)
            except ResponseError:
                raise IndexError('list assignment index out of range')
        return wrap 
开发者ID:brainix,项目名称:pottery,代码行数:10,代码来源:list.py


注:本文中的redis.ResponseError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。