mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-03 22:51:47 +08:00
refactor: reorganize backend module boundaries
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
from app.runtime.config import settings
|
||||
from app.foundation.singleton import Singleton
|
||||
|
||||
|
||||
class ThreadHelper(metaclass=Singleton):
|
||||
"""
|
||||
线程池管理
|
||||
"""
|
||||
def __init__(self):
|
||||
"""按系统配置创建共享后台线程池。"""
|
||||
self.pool = ThreadPoolExecutor(max_workers=settings.CONF.threadpool)
|
||||
|
||||
def submit(self, func, *args, **kwargs):
|
||||
"""
|
||||
提交任务
|
||||
:param func: 函数
|
||||
:param args: 参数
|
||||
:param kwargs: 参数
|
||||
:return: future
|
||||
"""
|
||||
return self.pool.submit(func, *args, **kwargs)
|
||||
|
||||
def shutdown(self):
|
||||
"""
|
||||
关闭线程池
|
||||
:return:
|
||||
"""
|
||||
self.pool.shutdown()
|
||||
Reference in New Issue
Block a user