From 20a70116b236a49d68659b451fea0a9f645a0835 Mon Sep 17 00:00:00 2001 From: Administrator <admin@example.com> Date: 星期一, 07 八月 2023 10:39:34 +0800 Subject: [PATCH] redis批量提交数据 --- trade/current_price_process_manager.py | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/trade/current_price_process_manager.py b/trade/current_price_process_manager.py index c66853f..2b96879 100644 --- a/trade/current_price_process_manager.py +++ b/trade/current_price_process_manager.py @@ -39,9 +39,11 @@ if True: _code_list = [] _delete_list = [] + prices = [] + rates = [] for d in prices: code, price = d["code"], float(d["price"]) - gpcode_manager.set_price(code, price) + prices.append((code, price)) # 鑾峰彇鏀剁洏浠� pricePre = gpcode_manager.CodePrePriceManager.get_price_pre_cache(code) if pricePre is not None: @@ -55,7 +57,7 @@ # 鏆傚瓨娑ㄥ箙涓鸿礋鐨勪唬鐮� _delete_list.append((rate, code, 0)) try: - __actualPriceProcessor.process_rate(code, rate, now_str) + rates.append((code, rate)) except Exception as e: logging.exception(e) @@ -66,7 +68,8 @@ decimal.Decimal(d["price"]))) except Exception as e: logging.exception(e) - + gpcode_manager.set_prices(prices) + __actualPriceProcessor.process_rates(rates, now_str) # -------------------------------澶勭悊浜ゆ槗浣嶇疆鍒嗛厤--------------------------------- # 鎺掑簭 new_code_list = sorted(_code_list, key=lambda e: (e.__getitem__(2), e.__getitem__(0)), reverse=True) -- Gitblit v1.8.0