线程,进程

线程


   from concurrent.futures.thread import ThreadPoolExecutor
   # 初始化线程池                    设置最大线程数
    executor = ThreadPoolExecutor(max_workers=5)
        for fn in range(10): # 任务数
            # 同步调用   一个个执行
            # executor.submit(zzz,fn,zk_client).result()
            # 异步调用  并行执行
            executor.submit(thread, fn)
    # 关闭线程池
    executor.shutdown()

进程

  import multiprocessing
    po = multiprocessing.Pool(2)  
    for file_name in range(10): # 任务数
        po.apply_async(exe, (bz2_path,))
    po.close()
    po.join()
原文地址:https://www.cnblogs.com/luochunxi/p/15473568.html