Python redis.BlockingConnectionPool() Examples
The following are 5
code examples of redis.BlockingConnectionPool().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
redis
, or try the search function
.
Example #1
Source File: config.py From sync-engine with GNU Affero General Public License v3.0 | 6 votes |
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
Example #2
Source File: redis_client.py From tcex with Apache License 2.0 | 5 votes |
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)
Example #3
Source File: mq.py From swift_rpc with MIT License | 5 votes |
def __init__(self, host, port): self._conn = redis.Redis(connection_pool=redis.BlockingConnectionPool(max_connections=15, host=host, port=port))
Example #4
Source File: redis-queue.py From stoq-plugins-public with Apache License 2.0 | 5 votes |
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 ), )
Example #5
Source File: context.py From panoptes with Apache License 2.0 | 4 votes |
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