学着。。
#!/usr/bin/env python # -*- coding: utf-8 -*- # Spawn a Process: Chapter 3: Process Based Parallelism import multiprocessing import time def foo(i): name = multiprocessing.current_process().name print("Starting %s \n" %name) print("called function in process: %s" %i) return if __name__ == "__main__": Process_jobs = [] for i in range(5): p = multiprocessing.Process(name='foo_process', target=foo, args=(i,)) Process_jobs.append(p) p.start() p.join()
时间: 2024-10-08 12:14:31