feat: base 添加全局线程池
This commit is contained in:
parent
74ece85b0a
commit
71ac63bdaf
|
@ -1,9 +1,17 @@
|
||||||
import threading
|
import threading
|
||||||
from apps.utils.decorators import auto_log
|
from apps.utils.decorators import auto_log
|
||||||
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
|
|
||||||
|
# 创建全局线程池
|
||||||
|
global_executor = ThreadPoolExecutor(max_workers=20)
|
||||||
class MyThread(threading.Thread):
|
class MyThread(threading.Thread):
|
||||||
|
|
||||||
@auto_log('MyThread', raise_exception=True, send_mail=True)
|
@auto_log('MyThread', raise_exception=True, send_mail=True)
|
||||||
def run(self) -> None:
|
def run(self) -> None:
|
||||||
return super().run()
|
return super().run()
|
||||||
|
|
||||||
|
def start_p(self):
|
||||||
|
"""
|
||||||
|
使用线程池启动
|
||||||
|
"""
|
||||||
|
global_executor.submit(self.run)
|
Loading…
Reference in New Issue