03 基于事件的进程通信

Posted work14

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了03 基于事件的进程通信相关的知识,希望对你有一定的参考价值。

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(结果已经写入文件了,可以拿到这值)

 

以上是关于03 基于事件的进程通信的主要内容,如果未能解决你的问题,请参考以下文章