Python 进程,子进程( multiprocessing.Process() )

来源:互联网 发布:基于大数据用户画像 编辑:程序博客网 时间:2024/06/06 08:58
import osimport multiprocessingdef info(title):    print(title)    print(__name__)    print("father ppid",os.getppid())    print("self pid", os.getpid())    print("-----------")if  __name__=="__main__":    info("hello")  #主进程的info()    #多进程    p=multiprocessing.Process(target=info,args=("zhangsan",))   #子进程的info()    p.start()    p.join()  #父亲进程必须等待子进程干完活,才会执行后续代码    print("hello  aaaaaa")

原创粉丝点击