Administrator
2023-11-14 5715545bec1d88fe9cc4ea79db0a5d1148694590
l2/l2_data_listen_manager.py
@@ -28,22 +28,28 @@
        __id = id(q)
        count = 0
        while True:
            datas_dict = {}
            # datas_dict = {}
            try:
                while not q.empty():
                if not q.empty():
                    item = q.get()
                    if item[0] not in datas_dict:
                        datas_dict[item[0]] = []
                    datas_dict[item[0]].append(item)
                if datas_dict:
                    for c in datas_dict:
                        self.my_l2_data_callback.OnL2Order(c, datas_dict[c], datas_dict[c][0][10])
                    self.my_l2_data_callback.OnL2Order(item[0], item[1], item[2])
                else:
                    time.sleep(0.002)
                    time.sleep(0.001)
                # while not q.empty():
                #     item = q.get()
                #     if item[0] not in datas_dict:
                #         datas_dict[item[0]] = []
                #     datas_dict[item[0]].append(item)
                # if datas_dict:
                #     for c in datas_dict:
                #         self.my_l2_data_callback.OnL2Order(c, datas_dict[c], datas_dict[c][0][10])
                # else:
                #     time.sleep(0.002)
            except Exception as e:
                async_log_util.exception(logger_debug, e)
            finally:
                datas_dict.clear()
                # datas_dict.clear()
                count += 1
                if count > 100:
                    count = 0
@@ -53,24 +59,29 @@
    # 接收L2逐笔成交数据
    def __recive_transaction_orders(self, q: multiprocessing.Queue):
        __id = id(q)
        datas_dict = {}
        # datas_dict = {}
        count = 0
        while True:
            try:
                while not q.empty():
                # while not q.empty():
                #     item = q.get()
                #     if item[0] not in datas_dict:
                #         datas_dict[item[0]] = []
                #     datas_dict[item[0]].append(item)
                # if datas_dict:
                #     for c in datas_dict:
                #         self.my_l2_data_callback.OnL2Transaction(c, datas_dict[c])
                # else:
                #     time.sleep(0.01)
                if not q.empty():
                    item = q.get()
                    if item[0] not in datas_dict:
                        datas_dict[item[0]] = []
                    datas_dict[item[0]].append(item)
                if datas_dict:
                    for c in datas_dict:
                        self.my_l2_data_callback.OnL2Transaction(c, datas_dict[c])
                    self.my_l2_data_callback.OnL2Transaction(item[0], item[1])
                else:
                    time.sleep(0.01)
                    time.sleep(0.005)
            except Exception as e:
                async_log_util.exception(logger_debug, e)
            finally:
                datas_dict.clear()
                # datas_dict.clear()
                count += 1
                if count > 50:
                    count = 0