1、导包
from concurrent.futures import ThreadPoolExecutor
2、初始化线程池
thread_pool_executor_insert_spider = ThreadPoolExecutor(max_workers=insert_spider_max_workers,
thread_name_prefix=insert_thread_name_prefix)
参数:
max_workers : 线程池最大得线程数
thread_name_prefix : 你的线程池名字
3、使用
thread_pool_executor_insert_spider.submit(func,1,2,3,4)
参数:
func: 所要执行得函数,比如一个while True 循环 后面得1234 func的参数,用,隔开依次往下写,不用放在括号中