Administrator
2023-08-03 4d321ae069fce2c0f6f7884bec8fa6c4ec534d1a
ths/l2_code_operate.py
@@ -110,7 +110,7 @@
        while True:
            cls.set_read_queue_valid()
            try:
                data =RedisUtils.lpop(redis,"code_operate_queue")
                data = RedisUtils.lpop(redis, "code_operate_queue", auto_free= False)
                # print("读取操作队列", data, redis.llen("code_operate_queue"))
                if data is not None:
                    data = json.loads(data)
@@ -186,10 +186,9 @@
        # 09:25:10之后才能操作
        if int(tool.get_now_time_str().replace(":", "")) < int("092510"):
            return
        redis = self.redis_manager_.getRedis()
        RedisUtils.rpush(redis, "code_operate_queue",
                    json.dumps({"type": type, "msg": msg, "code": code, "client": client, "pos": pos,
                                "create_time": round(time.time() * 1000)}))
        RedisUtils.rpush(self.redis_manager_.getRedis(), "code_operate_queue",
                         json.dumps({"type": type, "msg": msg, "code": code, "client": client, "pos": pos,
                                     "create_time": round(time.time() * 1000)}))
    def repaire_operate(self, client, pos, code):
        # 如果本来该位置代码为空则不用修复
@@ -210,8 +209,7 @@
            data = {"action": "repairL2Data",
                    "data": {"index": int(pos), "code": code, "min_price": float(min_price),
                             "max_price": float(max_price)}}
            redis = self.redis_manager_.getRedis()
            RedisUtils.rpush(redis, "code_operate_queue", json.dumps(
            RedisUtils.rpush(self.redis_manager_.getRedis(), "code_operate_queue", json.dumps(
                {"type": 3, "code": code, "client": client_id, "data": data, "create_time": round(time.time() * 1000)}))
    # 移除监控
@@ -223,7 +221,7 @@
    # 设置代码操作状态,服务器保存的代码是否与实际设置的代码保持一致
    @classmethod
    def set_operate_code_state(cls, client_id, channel, state):
        RedisUtils.setex(cls.getRedis(),"code-operate_state-{}-{}".format(client_id, channel), 10, state)
        RedisUtils.setex(cls.getRedis(), "code-operate_state-{}-{}".format(client_id, channel), 10, state)
    def get_operate_code_state(self, client_id, channel):
        value = RedisUtils.get(self.getRedis(), "code-operate_state-{}-{}".format(client_id, channel))
@@ -234,13 +232,11 @@
    # 设置读取队列有效
    @classmethod
    def set_read_queue_valid(cls):
        redis = cls.getRedis()
        RedisUtils.setex( redis,"operate_queue_read_state", 20, 1)
        RedisUtils.setex(cls.getRedis(), "operate_queue_read_state", 20, 1)
    @classmethod
    def is_read_queue_valid(cls):
        redis = cls.getRedis()
        return RedisUtils.get(redis, "operate_queue_read_state") is not None
        return RedisUtils.get(cls.getRedis(), "operate_queue_read_state") is not None
# 通过l2代码校验代码位