diff options
-rw-r--r-- | tipboard/app.py | 7 |
1 files changed, 6 insertions, 1 deletions
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): |