def run_proc(name):
print('Run child process %s (%s)...' % (name, os.getpid()))
if name=='main':
print('Parent process %s.' % os.getpid())
p = Process(target=run_proc, args=('test',))
print('Child process will start.')
p.start()
p.join()
print('Child process end.')
运行结果是:
Parent process 8768.
Child process will start.
Child process end.
大邱金草莓-vvv
from multiprocessing import Process import os
def run_proc(name): print('Run child process %s (%s)...' % (name, os.getpid())) if name=='main': print('Parent process %s.' % os.getpid()) p = Process(target=run_proc, args=('test',)) print('Child process will start.') p.start() p.join() print('Child process end.') 运行结果是: Parent process 8768. Child process will start. Child process end.