當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。