from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED, FIRST_COMPLETED
pool = ThreadPoolExecutor(max_workers=32)
# 批量把任务提交到线程池
tasks = [pool.submit(self.task_function, param) for param in all_task_param]
# 主线程阻塞等待线程池执行完毕
wait(tasks, return_when=ALL_COMPLETED)
上一篇
pandas-dataframe直接读写数据库
2023-04-16
下一篇