美文网首页
python ThreadPoolExecutor

python ThreadPoolExecutor

作者: Joncc | 来源:发表于2022-01-13 17:23 被阅读0次

    事例:

    from concurrent.futures import ThreadPoolExecutor, wait, ALL_COMPLETED, FIRST_COMPLETED
    def main(args):
        print(args)
    
    if __name__ == "__main__":
        executor = ThreadPoolExecutor(max_workers=3)
        all_task = [ executor.submit(main, (args))  for i in range(3)]
        wait(all_task, return_when=ALL_COMPLETED)
        print("finish")
    

    相关文章

      网友评论

          本文标题:python ThreadPoolExecutor

          本文链接:https://www.haomeiwen.com/subject/kwoncrtx.html