python ThreadPoolExecutor

2022-01-13  本文已影响0人  Joncc

事例:

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")
上一篇下一篇

猜你喜欢

热点阅读