获取进程信息
import os
os.getpid()
os.getppid()
多进程 multiprocessing的Process
multiprocessing提供一个Process代表进程对象。
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"
)
网友评论