From 2f2516749615da866e96d8d24e499b7ecbb63a3e Mon Sep 17 00:00:00 2001
From: Administrator <admin@example.com>
Date: 星期一, 23 六月 2025 12:28:52 +0800
Subject: [PATCH] 默认交易模式变更/真实下单位置计算位置修改

---
 log_module/async_log_util.py |   32 +++++++++++++++++++++-----------
 1 files changed, 21 insertions(+), 11 deletions(-)

diff --git a/log_module/async_log_util.py b/log_module/async_log_util.py
index 6640308..cac3f10 100644
--- a/log_module/async_log_util.py
+++ b/log_module/async_log_util.py
@@ -13,13 +13,19 @@
 class AsyncLogManager:
 
     def __init__(self):
-        self.__log_queue = queue.Queue()
+        self.__log_queue = queue.Queue(maxsize=10240)
 
     def __add_log(self, logger, method, *args):
-        self.__log_queue.put_nowait((logger, time.time(), method, args))
+        try:
+            self.__log_queue.put_nowait((logger, time.time(), method, args))
+        except Exception:
+            pass
 
     def add_log(self, data):
-        self.__log_queue.put_nowait(data)
+        try:
+            self.__log_queue.put_nowait(data)
+        except Exception:
+            pass
 
     def debug(self, logger, *args):
         self.__add_log(logger, "debug", *args)
@@ -36,9 +42,16 @@
     def exception(self, logger, *args):
         self.__add_log(logger, "exception", *args)
 
+    def get_queue_size(self):
+        """
+        鑾峰彇闃熷垪澶у皬
+        @return:
+        """
+        self.__log_queue.qsize()
+
     # 杩愯鍚屾鏃ュ織
     def run_sync(self, add_to_common_log=False):
-        print("run_sync", add_to_common_log)
+        # print("run_sync", add_to_common_log)
         logger_system.info(f"run_sync 绾跨▼ID:{tool.get_thread_id()}")
         while True:
             try:
@@ -91,10 +104,7 @@
 
 
 if __name__ == "__main__":
-    # info(logger_debug, "*-{}", "test")
-    asyncLogManager = AsyncLogManager()
-    asyncLogManager.info(logger_debug, "娴嬭瘯123")
-    threading.Thread(target=lambda: asyncLogManager.run_sync(), daemon=True).start()
-    time.sleep(1)
-    # info(logger_debug, "002375")
-    run_sync()
+    _queue = queue.Queue(maxsize=102400)
+    for i in range(200):
+        _queue.put_nowait("1")
+

--
Gitblit v1.8.0