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


Python redis.BlockingConnectionPool方法代码示例

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


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

示例1: _get_redis_connection_pool

# 需要导入模块: import redis [as 别名]
# 或者: from redis import BlockingConnectionPool [as 别名]
def _get_redis_connection_pool(host, port, db):
    # This function is called once per sync process at the time of
    # instantiating the singleton HeartBeatStore, so doing this here
    # should be okay for now.
    # TODO[k]: Refactor.
    global connection_pool_map

    connection_pool = connection_pool_map.get(host)
    if connection_pool is None:
        connection_pool = BlockingConnectionPool(
            host=host, port=port, db=db,
            max_connections=MAX_CONNECTIONS, timeout=WAIT_TIMEOUT,
            socket_timeout=SOCKET_TIMEOUT)
        connection_pool_map[host] = connection_pool

    return connection_pool 
开发者ID:nylas,项目名称:sync-engine,代码行数:18,代码来源:config.py

示例2: __init__

# 需要导入模块: import redis [as 别名]
# 或者: from redis import BlockingConnectionPool [as 别名]
def __init__(self, host='localhost', port=6379, db=0, blocking_pool=False, **kwargs):
        """Initialize class properties"""
        self._client = None
        pool = redis.ConnectionPool
        if blocking_pool:
            pool = redis.BlockingConnectionPool
        self.pool = pool(host=host, port=port, db=db, **kwargs) 
开发者ID:ThreatConnect-Inc,项目名称:tcex,代码行数:9,代码来源:redis_client.py

示例3: __init__

# 需要导入模块: import redis [as 别名]
# 或者: from redis import BlockingConnectionPool [as 别名]
def __init__(self, host, port):
        self._conn = redis.Redis(connection_pool=redis.BlockingConnectionPool(max_connections=15, host=host, port=port)) 
开发者ID:rfyiamcool,项目名称:swift_rpc,代码行数:4,代码来源:mq.py

示例4: _connect

# 需要导入模块: import redis [as 别名]
# 或者: from redis import BlockingConnectionPool [as 别名]
def _connect(self):
        self.conn = redis.Redis(
            host=self.redis_host,
            port=self.redis_port,
            socket_keepalive=True,
            socket_timeout=300,
            connection_pool=redis.BlockingConnectionPool(
                max_connections=self.max_connections
            ),
        ) 
开发者ID:PUNCH-Cyber,项目名称:stoq-plugins-public,代码行数:12,代码来源:redis-queue.py

示例5: _get_redis_connection

# 需要导入模块: import redis [as 别名]
# 或者: from redis import BlockingConnectionPool [as 别名]
def _get_redis_connection(self, group, shard):
        """
        Create and return a Redis Connection for the given group

        Returns:
            redis.StrictRedis: The Redis Connection

        Raises:
            Exception: Passes through any exceptions that happen in trying to get the connection pool
        """
        redis_group = self.__config.redis_urls_by_group[group][shard]

        self.__logger.info(u'Attempting to connect to Redis for group "{}", shard "{}", url "{}"'.format(group, shard,
                                                                                                         redis_group))

        if isinstance(redis_group, PanoptesRedisConnectionConfiguration):

            redis_pool = redis.BlockingConnectionPool(host=redis_group.host,
                                                      port=redis_group.port,
                                                      db=redis_group.db,
                                                      password=redis_group.password)
            redis_connection = redis.StrictRedis(connection_pool=redis_pool)
        elif isinstance(redis_group, PanoptesRedisSentinelConnectionConfiguration):

            sentinels = [(sentinel.host, sentinel.port) for sentinel in redis_group.sentinels]
            self.__logger.info(u'Querying Redis Sentinels "{}" for group "{}", shard "{}"'.format(repr(redis_group),
                                                                                                  group, shard))

            sentinel = redis.sentinel.Sentinel(sentinels)
            master = sentinel.discover_master(redis_group.master_name)
            password_present = u'yes' if redis_group.master_password else u'no'
            self.__logger.info(u'Going to connect to master "{}" ({}:{}, password: {}) for group "{}", shard "{}""'
                               .format(redis_group.master_name, master[0], master[1], password_present, group, shard))
            redis_connection = sentinel.master_for(redis_group.master_name, password=redis_group.master_password)
        else:

            self.__logger.info(u'Unknown Redis configuration object type: {}'.format(type(redis_group)))
            return

        self.__logger.info(u'Successfully connected to Redis for group "{}", shard "{}", url "{}"'.format(group,
                                                                                                          shard,
                                                                                                          redis_group))

        return redis_connection 
开发者ID:yahoo,项目名称:panoptes,代码行数:46,代码来源:context.py


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