进程池
code
import os import time from concurrent.futures.process import ProcessPoolExecutor def test(n): print(f'n:{n}-os.getpid:{os.getpid()}') time.sleep(2) return 'helllo' def call_back(n): print(f'callback:n.result{n.result()}') if __name__ == '__main__': pool = ProcessPoolExecutor(5) print('zhu') t_list = [] for i in range(20): res = pool.submit(test, i) t_list.append(res) print(f't_list:{t_list}')