import time
from multiprocessing import Process,Event
def f1(e):
time.sleep(2)
n = 100
print("子进程计算结果位:",n)
e.set()
if __name__ == '__main__':
e = Event()
p = Process(target=f1,args=(e,))
p.start() print("主进程等待")
e.wait()
print("结果已经写入文件了,可以拿到这值")
2024-01-07 15:07:10
import time
from multiprocessing import Process,Event
def f1(e):
time.sleep(2)
n = 100
print("子进程计算结果位:",n)
e.set()
if __name__ == '__main__':
e = Event()
p = Process(target=f1,args=(e,))
p.start() print("主进程等待")
e.wait()
print("结果已经写入文件了,可以拿到这值")