fix(SearchChain): with 关闭线程池

- 使用 with 语句管理 ThreadPoolExecutor,确保线程池正确关闭
This commit is contained in:
shaw
2025-05-25 00:44:19 +08:00
parent 72fce20905
commit 677e38c62d
+3 -3
View File
@@ -329,8 +329,10 @@ class SearchChain(ChainBase):
self.progress.update(value=0,
text=f"开始搜索,共 {total_num} 个站点 ...",
key=ProgressKey.Search)
# 结果集
results = []
# 多线程
executor = ThreadPoolExecutor(max_workers=len(indexer_sites))
with ThreadPoolExecutor(max_workers=len(indexer_sites)) as executor:
all_task = []
for site in indexer_sites:
if area == "imdbid":
@@ -346,8 +348,6 @@ class SearchChain(ChainBase):
mtype=mediainfo.type if mediainfo else None,
page=page)
all_task.append(task)
# 结果集
results = []
for future in as_completed(all_task):
if global_vars.is_system_stopped:
break