GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — learn-python3/task/multi_process.py at master · best90/learn-python3 Expand file tree/ Copy pathmulti_process.pyMore file actions 18 lines (15 loc) · 676 Bytes / Copy pathmulti_process.pyFile metadata and controls18 lines (15 loc) · 676 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #!/usr/bin/env python3 # -*- coding: utf-8 -*- 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.') # 创建子进程时,只需要传入一个执行函数和函数的参数,创建一个Process实例,用start()方法启动,这样创建进程比fork()还要简单 p.start() # join()方法可以等待子进程结束后再继续往下运行,通常用于进程间的同步 p.join() print('Child process end.') |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |