首页 > 编程语言 > 详细

python 管道

时间:2019-01-29 13:06:51      阅读:159      评论:0      收藏:0      [点我收藏+]

 

#- * -coding: utf - 8 - * -
from multiprocessing import Process, Pipe

def f(conn):
    conn.send([42, None, hello])
    while True:
        print(conn.recv())

if __name__ == __main__:
    parent_conn, child_conn = Pipe()
    p = Process(target = f, args = (child_conn, ))
    p.start()
    print(parent_conn.recv())# prints "[42, None, ‘hello‘]"
    parent_conn.send(666)
    p.terminate()

输出

[42, None, hello]

 

python 管道

原文:https://www.cnblogs.com/sea-stream/p/10333514.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!