aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Mieszkowski <tomasz.mieszkowski@ext.allegro.pl>2014-09-05 11:32:54 +0200
committerTomasz Mieszkowski <tomasz.mieszkowski@ext.allegro.pl>2014-09-05 11:32:54 +0200
commitb76b19b62c572f02adbfbc462defe875ae4a04c5 (patch)
treeb17d18c556e06aef1bfb288498f7cf3464201d6a
parent271876565f47da27d9a52af9e9bec705cad0cf18 (diff)
downloadtipboard-b76b19b62c572f02adbfbc462defe875ae4a04c5.tar.gz
tipboard-b76b19b62c572f02adbfbc462defe875ae4a04c5.tar.bz2
tipboard-b76b19b62c572f02adbfbc462defe875ae4a04c5.zip
Fix for tiles' keys cache.
-rw-r--r--tipboard/app.py7
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):