Пример #1
0
class MqttPushDelegate():
    def __init__(self, app):
        self.redis = app.redis
        self.mqtt_client = None
        self.push_handler = PushHandler(self)
        return

    def outdate(self):
        _delta = datetime.timedelta(seconds=30)
        if self.mqtt_client == None:
            return
        self.mqtt_client.outdate(_delta)
        return

    def push(self):
        while True:
            _request = self.redis.lpop(REDIS_MQTTPUSH_KEY)
            if _request == None or len(_request) == 0:
                return
            _request = json.loads(_request)
            self.push_handler.task(_request)
        return

    def run_periodic(self):
        tornado.ioloop.PeriodicCallback(self.outdate, 1000 * 30).start()
        tornado.ioloop.PeriodicCallback(self.push, 1000).start()
        return
Пример #2
0
class MqttPushDelegate():
    def __init__(self, app):
        self.redis = app.redis
        self.mqtt_client = None
        self.push_handler = PushHandler(self)
        return
        
    def outdate(self):
        _delta = datetime.timedelta(seconds=30)
        if self.mqtt_client == None:
            return
        self.mqtt_client.outdate(_delta)
        return

    def push(self):
        while True:
            _request = self.redis.lpop(REDIS_MQTTPUSH_KEY)
            if _request == None or len(_request) == 0:
                return
            _request = json.loads(_request)
            self.push_handler.task(_request)
        return

    def run_periodic(self):
        tornado.ioloop.PeriodicCallback(self.outdate, 1000*30).start()
        tornado.ioloop.PeriodicCallback(self.push, 1000).start()
        return
Пример #3
0
class MqttPushApp():
    def __init__(self, *args, **kwargs):
        self._mqtt_client = None
        self.push_handler = PushHandler(self)
        self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
        return

    def outdate(self):
        _delta = datetime.timedelta(seconds=30)
        if self._mqtt_client == None:
            return
        self._mqtt_client.outdate(_delta)
        return

    def push(self):
        while True:
            _request = self.redis.lpop(REDIS_MQTTPUSH_KEY)
            if _request == None or len(_request) == 0:
                return
            _request = json.loads(_request)
            self.push_handler.task(_request)
        return
Пример #4
0
class MqttPushApp():
    def __init__(self, *args, **kwargs):
        self._mqtt_client = None
        self.push_handler = PushHandler(self)
        self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
        return

    def outdate(self):
        _delta = datetime.timedelta(seconds=30)
        if self._mqtt_client == None:
            return
        self._mqtt_client.outdate(_delta)
        return

    def push(self):
        while True:
            _request = self.redis.lpop(REDIS_MQTTPUSH_KEY)
            if _request == None or len(_request) == 0:
                return
            _request = json.loads(_request)
            self.push_handler.task(_request)
        return
Пример #5
0
 def __init__(self, app):
     self.redis = app.redis
     self.mqtt_client = None
     self.push_handler = PushHandler(self)
     return
Пример #6
0
 def __init__(self, *args, **kwargs):
     self._mqtt_client = None
     self.push_handler = PushHandler(self)
     self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
     return
Пример #7
0
 def __init__(self, *args, **kwargs):
     self._mqtt_client = None
     self.push_handler = PushHandler(self)
     self.redis = redis.Redis(REDIS_HOST, REDIS_PORT, db=1)
     return
Пример #8
0
 def __init__(self, app):
     self.redis = app.redis
     self.mqtt_client = None
     self.push_handler = PushHandler(self)
     return