Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 import rospy
00008 import redis
00009 import threading
00010
00011
00012
00013
00014 class ConcertMasterDiscovery(threading.Thread):
00015 params = {}
00016
00017 def __init__(self, hub_client, key, processNewMaster):
00018 threading.Thread.__init__(self)
00019 self.hub_client = hub_client
00020 self.concertmasterlist_key = key
00021 self.processNewMaster = processNewMaster
00022 self._stop = False
00023 self.masterlist = []
00024
00025 def run(self):
00026 rospy.loginfo("Concert Client : concert discovery has started")
00027
00028 while not rospy.is_shutdown() and not self._stop:
00029 try:
00030 discovered_masterlist = self.getMasterList()
00031 self.processNewMaster(discovered_masterlist)
00032 rospy.sleep(3)
00033 except redis.ConnectionError as e:
00034
00035 rospy.logwarn("Concert Client : lost connection to the hub [%s]" % str(e))
00036 break
00037 rospy.loginfo("Concert Client : concert discovery has stopped")
00038
00039 def getMasterList(self):
00040 return self.hub_client.getValues(self.concertmasterlist_key)
00041
00042 def set_stop(self):
00043 self._stop = True