def dispatcher_routine(self):
        """This listens dispatcher redis channel and send data through channel
        """
        sub = RedisConn.pubsub()
        log.info('subscribing to %s' % self.subscribe_name)
        sub.subscribe(self.subscribe_name)
        for msg in sub.listen():
            if not 'type' in msg:
                continue

            if msg['type'] != 'message':
                continue

            log.info('CHANNEL %s < DISPATCHER MESSAGE %s' % (self, msg))
            self._send_ws(json.loads(msg['data']))
    def dispatcher_routine(self):
        """This listens dispatcher redis channel and send data through channel
        """
        sub = RedisConn.pubsub()
        log.info('subscribing to %s' % self.subscribe_name)
        sub.subscribe(self.subscribe_name)
        for msg in sub.listen():
            if not 'type' in msg:
                continue

            if msg['type'] != 'message':
                continue

            log.info('CHANNEL %s < DISPATCHER MESSAGE %s' % (self, msg))
            self._send_ws(json.loads(msg['data']))
 def _listener():
     pb = RedisConn.pubsub()
     _pubsub = pb.subscribe(channel_name)
     if on_spawn:
         on_spawn(_pubsub)
     for msg in pb.listen():
         try:
             if termination and termination(channel_name):
                 # it could be unsubscribe here
                 return
             if msg['type'] == 'message':
                 SESSION.begin()
                 action(msg, channel_name)
         finally:
             gevent.sleep(0)
             SESSION.close()
Exemple #4
0
 def _listener():
     pb = RedisConn.pubsub()
     _pubsub = pb.subscribe(channel_name)
     if on_spawn:
         on_spawn(_pubsub)
     for msg in pb.listen():
         try:
             if termination and termination(channel_name):
                 # it could be unsubscribe here
                 return
             if msg['type'] == 'message':
                 SESSION.begin()
                 action(msg, channel_name)
         finally:
             gevent.sleep(0)
             SESSION.close()