def connect(self): if self.m_debug: if self.m_redis_password: self.lg("Connecting to Secure Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") DB(" + str(self.m_db) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) else: self.lg("Connecting to Unsecure Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") DB(" + str(self.m_db) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) # end of debugging self.m_rw = RedisWrapper(self.m_queue_name, serializer=pickle, host=self.m_host_address, port=int(self.m_port), db=int(self.m_db), password=self.m_redis_password) return None
def connect(self): if self.m_debug: self.lg( "PubR Connecting to Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) self.m_rw = RedisWrapper(self.m_queue_name, serializer=pickle, host=self.m_host_address, port=int(self.m_port), db=0) return None
class RedisPickleApplication(BaseRedisApplication): def __init__(self, name, redis_address, redis_port, redis_queue, logger, request_key_name=None, response_key_name=None, debug=False): BaseRedisApplication.__init__(self, name, redis_address, redis_port, redis_queue, logger, request_key_name, response_key_name, debug) # end of __init__ def disconnect(self): if self.m_debug: self.lg("PubR Disconnecting from Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) if self.m_rw: self.m_rw.client_kill() return None # end of disconnect def connect(self): if self.m_debug: if self.m_redis_password: self.lg("Connecting to Secure Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") DB(" + str(self.m_db) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) else: self.lg("Connecting to Unsecure Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") DB(" + str(self.m_db) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) # end of debugging self.m_rw = RedisWrapper(self.m_queue_name, serializer=pickle, host=self.m_host_address, port=int(self.m_port), db=int(self.m_db), password=self.m_redis_password) return None # end of connect def get_address(self): return str(self.m_host_address) + ":" + str(self.m_port) # end of get_address def get_single_cache(self, key=None): if key == None: key = self.m_queue_name # By default RedisWrapper returns None when the timeout is hit msg = None try: # By default RedisWrapper returns None when the timeout is hit msg = self.m_rw.get_cached_single_set(key) except ValueError, e: self.lg("ERROR: Address(" + self.m_host_address + ":" + str(self.m_port) + ") Queue(" + key + ") Received a Non-Pickle Formatted Message Ex(" + str(e) +")", 0) except Exception, e: test_for_redis_connectivity = str(e) if "Connection refused." in test_for_redis_connectivity: self.lg("ERROR: Connection Failed to Redis Address(" + self.m_host_address + ":" + str(self.m_port) + ") Queue(" + key + ") Pickle Encountered Ex(" + str(e) +") sleeping(" + str(self.m_sleep_for_connection_outage) + ")", 0) sleep(self.m_sleep_for_connection_outage) else: self.lg("Possible Error but the cache may not exist: Address(" + self.m_host_address + ":" + str(self.m_port) + ") Queue(" + key + ") Pickle Encountered Ex(" + str(e) +")", 7)
def connect(self): if self.m_debug: self.lg("PubR Connecting to Redis(" + str(self.m_host_address) + ":" + str(self.m_port) + ") with Pickle queue(" + str(self.m_queue_name) + ")", 7) self.m_rw = RedisWrapper(self.m_queue_name, serializer=pickle, host=self.m_host_address, port=int(self.m_port), db=0) return None