print("Test Process")
# 导入进程模块
from multiprocessing import Process
import time, os
# 创建进程 进程入口函数 进程参数(是个元组类型)
def proc_func(name):
print("proc_func")
for j in range(10):
# 打印进程号
print(j, "child func", name, os.getpid())
time.sleep(1)
# 进程在主模块中创建
if __name__ == "__main__":
proc1 = Process(target = proc_func, args = ("name001", ))
# 启动进程
proc1.start()
for i in range(10):
print(i, "parent func", os.getpid())
time.sleep(1)
32、python多进程编程代码演示
猜你喜欢
转载自blog.csdn.net/zhaopeng01zp/article/details/109317777
今日推荐
周排行