From cc6fcdf8e3792d17ccf436fb2f03fcda57b0f06a Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期二, 15 八月 2023 17:11:28 +0800
Subject: [PATCH] ++++++++++++++++ bug修复-

---
 trade/huaxin/trade_api_server.py |   64 +++++++++-----------------------
 1 files changed, 18 insertions(+), 46 deletions(-)

diff --git a/trade/huaxin/trade_api_server.py b/trade/huaxin/trade_api_server.py
index 72c01fa..bb16576 100644
--- a/trade/huaxin/trade_api_server.py
+++ b/trade/huaxin/trade_api_server.py
@@ -420,58 +420,30 @@
         super().finish()
 
 
-test_data = [('600829', 60024, 8.33), ('603610', 40000, 12.5), ('002945', 28474, 17.56), ('600689', 47438, 10.54),
-             ('002907', 26288, 19.02), ('002999', 60680, 8.24), ('601136', 18939, 26.4), ('603190', 16062, 31.13),
-             ('001231', 21844, 22.89), ('605138', 50454, 9.91), ('603963', 37850, 13.21), ('603029', 21608, 23.14),
-             ('001222', 29833, 16.76), ('002898', 34868, 14.34), ('603106', 58754, 8.51), ('600361', 80775, 6.19),
-             ('600280', 92251, 5.42), ('002370', 100402, 4.98), ('002640', 124378, 4.02), ('002758', 37821, 13.22),
-             ('000953', 82237, 6.08), ('002747', 20602, 24.27), ('002146', 191571, 2.61), ('601696', 39620, 12.62),
-             ('000411', 31566, 15.84), ('603220', 26810, 18.65), ('000739', 26137, 19.13), ('600575', 174825, 2.86),
-             ('600257', 72464, 6.9), ('003042', 22686, 22.04), ('601059', 24522, 20.39), ('603667', 33400, 14.97)]
-
-
 def __set_target_codes(pipe_l2):
     while True:
         try:
-            datas = test_data
-            root_data = {"data": {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2,
-                                  "data": datas},
-                         "request_id": f"{ClientSocketManager.CLIENT_TYPE_CMD_L2}_{round(time.time() * 1000)}"}
-            root_data = socket_util.encryp_client_params_sign(root_data)
-            pipe_l2.send(json.dumps(root_data))
-            print("鍚慙2鍙戦�佹暟鎹�")
-
+            _datas = huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.pop()
+            if _datas:
+                timestamp = _datas[0]
+                datas = _datas[1]
+                print("鏃堕棿鎴筹細", timestamp)
+                print("鍐呭锛�", datas)
+                # 鍙鐞�20s鍐呯殑鏁版嵁
+                if time.time() - timestamp < 20 and datas:
+                    codes = [d[0] for d in datas]
+                    for code in codes:
+                        block_info.init_code(code)
+                    root_data = {"data": {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2,
+                                          "data": datas},
+                                 "request_id": f"{ClientSocketManager.CLIENT_TYPE_CMD_L2}_{round(time.time() * 1000)}"}
+                    root_data = socket_util.encryp_client_params_sign(root_data)
+                    pipe_l2.send(json.dumps(root_data))
+                    print("璁剧疆L2浠g爜缁撴潫")
         except Exception as e:
             logging.exception(e)
         finally:
-            time.sleep(2)
-
-
-#
-# def __set_target_codes(pipe_l2):
-#     while True:
-#         try:
-#             _datas = huaxin_target_codes_manager.HuaXinL2SubscriptCodesManager.pop()
-#             if _datas:
-#                 timestamp = _datas[0]
-#                 datas = _datas[1]
-#                 print("鏃堕棿鎴筹細", timestamp)
-#                 print("鍐呭锛�", datas)
-#                 # 鍙鐞�20s鍐呯殑鏁版嵁
-#                 if time.time() - timestamp < 20 and datas:
-#                     codes = [d[0] for d in datas]
-#                     for code in codes:
-#                         block_info.init_code(code)
-#                     root_data = {"type": ClientSocketManager.CLIENT_TYPE_CMD_L2,
-#                                  "data": datas,
-#                                  "request_id": f"{ClientSocketManager.CLIENT_TYPE_CMD_L2}_{round(time.time() * 1000)}"}
-#                     root_data = socket_util.encryp_client_params_sign(root_data)
-#                     pipe_l2.send(json.dumps(root_data))
-#                     print("璁剧疆L2浠g爜缁撴潫")
-#         except Exception as e:
-#             logging.exception(e)
-#         finally:
-#             time.sleep(1)
+            time.sleep(1)
 
 
 def __read_sync_task(pipe):

--
Gitblit v1.8.0