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
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
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
def __init__(self, app): self.redis = app.redis self.mqtt_client = None self.push_handler = PushHandler(self) return
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