1
#Process pool, thread pool from concurrent.futures import ProcessPoolExecutor, ThreadPoolExecutor import os import time def task(name): print('%s is running 《pid: %s》' % (name, os.getpid())) time.sleep(2) if __name__ == ' __main__ ' : # p = Process(target=task, args=('child',)) # p.start pool = ProcessPoolExecutor(4) #Process pool max_workers: 4 for i in range(10) : #A total of 10 executions, each time 4 processes are executed pool.submit(task, ' child process%s ' % i) print ( ' main ' )
2
3
4
5