python使用ThreadPoolExecutor构造线程池

  • Post author:
  • Post category:python


当执行单元相对独立时,可采用多线程的方式提高执行效率;

1、导入创建线程池库:

from concurrent.futures import ThreadPoolExecutor

2、构建线程池:with ThreadPoolExecutor(max_workers=10) as executor:

3、在线程池中获取线程执行可执行的单元信息:

execute_testsuite_by_testsuite_id:执行方法名
sys_id, host_ip, testsuite_id_list[i - 1]:执行方法参数

4、当需要获取执行单元返回结果:使用xx.result()获取返回信息



版权声明:本文为weixin_39784577原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。