From 71ac63bdaf611ec7c935ab6e49a53cfd1999a06c Mon Sep 17 00:00:00 2001 From: caoqianming Date: Wed, 9 Oct 2024 13:46:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20base=20=E6=B7=BB=E5=8A=A0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E7=BA=BF=E7=A8=8B=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/utils/thread.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/utils/thread.py b/apps/utils/thread.py index 5276955e..419dbcea 100644 --- a/apps/utils/thread.py +++ b/apps/utils/thread.py @@ -1,9 +1,17 @@ import threading from apps.utils.decorators import auto_log +from concurrent.futures import ThreadPoolExecutor +# 创建全局线程池 +global_executor = ThreadPoolExecutor(max_workers=20) class MyThread(threading.Thread): @auto_log('MyThread', raise_exception=True, send_mail=True) def run(self) -> None: return super().run() - \ No newline at end of file + + def start_p(self): + """ + 使用线程池启动 + """ + global_executor.submit(self.run) \ No newline at end of file