Skip to content

Instantly share code, notes, and snippets.

@kannan4k
Created August 4, 2015 15:58
Show Gist options
  • Save kannan4k/d876a4997958f7b93952 to your computer and use it in GitHub Desktop.
Save kannan4k/d876a4997958f7b93952 to your computer and use it in GitHub Desktop.
class KmlUpdateHandler(tornado.web.RequestHandler):
counter = 0
timeout = 10
global_dict = {}
lock = threading.Lock()
@classmethod
def add_to_global_dict(cls, reference, unique_id):
cls.global_dict[unique_id] = reference
@classmethod
def get_unique_id(cls):
with cls.lock:
unique_id = cls.counter
cls.counter += 1
return unique_id
@classmethod
def finish_all_requests(cls):
for req in cls.global_dict.itervalues():
req.get(True)
cls.global_dict = {}
@classmethod
def get_scene_msg(cls, msg):
try:
cls.finish_all_requests()
except Exception as e:
rospy.loginfo("Exception getting scene changes"+str(e))
pass
def initialize(self):
self.asset_service = self.application.asset_service
def get(self):
yield gen.sleep(KmlUpdateHandler.timeout)
if self.unique_id in KmlUpdateHandler.global_dict:
del KmlUpdateHandler.global_dict[self.unique_id]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment