def test_should_return_none(self): config.redis_mode = None with self.assertRaises(AttributeError) as err: client = redis_client() expect(str(err.exception)).to_equal( "redis-mode must be either single_node or sentinel" )
def test_should_connect_to_redis_single_node_no_pass(self): config.redis_host = "localhost" config.redis_port = 6380 config.redis_database = 0 config.redis_password = None config.redis_mode = "single_node" client = redis_client() expect(client).not_to_be_null() expect(str(client)).to_equal( "Redis<ConnectionPool<Connection<host=localhost,port=6380,db=0>>>" )
def test_should_connect_to_redis_sentinel_no_pass(self): config.redis_mode = "sentinel" config.redis_sentinel_instances = "localhost:26379" config.redis_sentinel_password = None config.redis_sentinel_master_instance = "redismaster" config.redis_sentinel_master_password = None config.redis_sentinel_master_database = 0 config.redis_sentinel_socket_timeout = 10.0 client = redis_client() expect(client).not_to_be_null() expect(str(client)).to_equal( "Redis<SentinelConnectionPool<service=redismaster(master)>" )
def start_pyres_worker(): from remotecv.unique_queue import ( # NOQA pylint: disable=import-outside-toplevel UniqueWorker, ) redis = redis_client() def after_fork(_): config.error_handler.install_handler() worker = UniqueWorker(queues=["Detect"], server=redis, timeout=config.timeout, after_fork=after_fork) worker.work()
def __init__(self, config): super().__init__(config) if not ResultStore.redis_instance: ResultStore.redis_instance = redis_client() self.storage = ResultStore.redis_instance