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