From b76b19b62c572f02adbfbc462defe875ae4a04c5 Mon Sep 17 00:00:00 2001 From: Tomasz Mieszkowski Date: Fri, 5 Sep 2014 11:32:54 +0200 Subject: Fix for tiles' keys cache. --- tipboard/app.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tipboard/app.py b/tipboard/app.py index 59f93b4..a31ff1b 100644 --- a/tipboard/app.py +++ b/tipboard/app.py @@ -118,21 +118,26 @@ class DashboardSocketHandler(tornado.websocket.WebSocketHandler, RedisMixin, self.pubsub.disconnect() self.getter.disconnect() + @tornado.gen.engine def on_message(self, message): log.info('Message received: %s.', message) if message != 'update': return + stale_keys = set() for tile_id in self.cache: log.debug('Putting data for tile: {}'.format(tile_id)) raw = yield tornado.gen.Task(self.getter.get, tile_id) if not raw: log.warn('No data in key %s on Redis.', tile_id) - del self.cache[tile_id] + stale_keys.add(tile_id) continue data = json.loads(raw) data['tipboard'] = self.tipboard_helpers self.write_message(data) + if stale_keys: + self.cache.difference_update(stale_keys) + @tornado.gen.engine def on_publish(self, msg): -- cgit v1.2.3