fix: Prevent double-prefixing of S2A team names and refactor Telegram bot's thread pool usage for non-blocking execution.
This commit is contained in:
@@ -3985,18 +3985,16 @@ class ProvisionerBot:
|
||||
if worker_id in current_steps:
|
||||
del current_steps[worker_id]
|
||||
|
||||
# 使用线程池并发执行
|
||||
# 使用线程池并发执行 (通过 run_in_executor 避免阻塞 event loop)
|
||||
import concurrent.futures
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=workers) as executor:
|
||||
futures = [executor.submit(worker_task, i) for i in range(workers)]
|
||||
|
||||
# 等待所有任务完成
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
try:
|
||||
future.result()
|
||||
except Exception as e:
|
||||
log.error(f"Worker 异常: {e}")
|
||||
async_futures = [loop.run_in_executor(executor, worker_task, i) for i in range(workers)]
|
||||
results_done = await asyncio.gather(*async_futures, return_exceptions=True)
|
||||
for r in results_done:
|
||||
if isinstance(r, Exception):
|
||||
log.error(f"Worker 异常: {r}")
|
||||
|
||||
# 检查是否被停止
|
||||
stopped = False
|
||||
|
||||
Reference in New Issue
Block a user