From 457f3d4ca0c33ea41055de2e45c4218e3f541d02 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期二, 15 八月 2023 14:02:38 +0800 Subject: [PATCH] ++++++++++++++++ bug修复- --- huaxin_api/l2_client.py | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/huaxin_api/l2_client.py b/huaxin_api/l2_client.py index 20abba7..969e696 100644 --- a/huaxin_api/l2_client.py +++ b/huaxin_api/l2_client.py @@ -506,7 +506,7 @@ api.Init() -def __receive_from_pipe(pipe): +def __receive_from_pipe_trade(pipe): while True: try: value = pipe.recv() @@ -517,17 +517,31 @@ volume = data["data"]["volume"] code = data["data"]["code"] spi.set_code_special_watch_volume(code, volume) - elif data["type"] == "set_l2_codes": + except: + pass + + +def __receive_from_pipe_strategy(pipe): + while True: + try: + value = pipe.recv() + if value: + value = value.decode("utf-8") + data = json.loads(value) + if data["type"] == "set_l2_codes": data = data["data"] l2CommandManager.process_command(command_manager.CLIENT_TYPE_CMD_L2, None, data) except: pass -def run(pipe_trade=None): +def run(pipe_trade=None, pipe_strategy=None): __init_l2() if pipe_trade is not None: - t1 = threading.Thread(target=lambda: __receive_from_pipe(pipe_trade), daemon=True) + t1 = threading.Thread(target=lambda: __receive_from_pipe_trade(pipe_trade), daemon=True) + t1.start() + if pipe_strategy is not None: + t1 = threading.Thread(target=lambda: __receive_from_pipe_strategy(pipe_strategy), daemon=True) t1.start() l2_data_manager.run_upload_common() global l2CommandManager -- Gitblit v1.8.0