python - How to use Redis to manage connections for tornado websocket -


i have tornado server tornadio2 handling websocket , tornadoredis publish realtime messages clients (code merged several examples).

redis_client = tornadoredis.client(config.get('cache', 'host'), int(config.get('cache', 'port'))) redis_client.connect()  class realtimehandler(tornadio2.conn.socketconnection):     def __init__(self, *args, **kwargs):         super(realtimehandler, self).__init__(*args, **kwargs)         self.listen()      @tornado.gen.engine     def listen(self):         self.client = tornadoredis.client(config.get('cache', 'host'), int(config.get('cache', 'port')))         self.client.connect()         yield tornado.gen.task(self.client.subscribe, 'invalidation')         self.client.listen(self.on_message)      def on_event(self, name, *args, **kwargs):         if name == 'invalidation':             redis_client.publish('invalidation', kwargs['args'])      def on_message(self, msg):         if msg.kind == 'message':             self.send(msg.body)      def on_close(self):         if self.client.subscribed:             self.client.unsubscribe('invalidation')             self.client.disconnect() 

this code works, , now, want store connections in redis accomplish 2 things: 1. support redundancy server 2. able use connections if restart tornado

i saw several examples global list used save connections of course won't solve issues above.

so, how accomplish this?

on different note, setup? how compared node.js socket.io , redis?


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -