feat: base 添加全局线程池

This commit is contained in:
caoqianming 2024-10-09 13:46:38 +08:00
parent 74ece85b0a
commit 71ac63bdaf
1 changed files with 9 additions and 1 deletions

View File

@ -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()
def start_p(self):
"""
使用线程池启动
"""
global_executor.submit(self.run)