process pool, thread pool

Knowledge reserve

 

"""
 Pool: Mount a fixed amount of media, the media is worth a process or thread
    Why use it?
        Let the machine ensure an efficient work within its own affordable range

from concurrent.futures import ProcessPoolExecutor,ThreadPoolExecutor

pool = ProcessPoolExecutor() # The default is cpu.count
pool.submit(task,args1,args2,...)    
pool.shutdown(wait=Ture) # shutdown is worth not submitting tasks to the process pool, wati=True is to wait for the task execution in the process pool or thread pool to complete 

future.result()
"""

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324979786&siteId=291194637