python使用Queue在多个子进程间交换数据的方法 -电脑资料

电脑资料 时间:2019-01-01 我要投稿
【meiwen.anslib.com - 电脑资料】

    作者:work24 字体:[增加 减小] 类型:转载

    这篇文章主要介绍了python使用Queue在多个子进程间交换数据的方法,实例分析了Queue实现进程间数据交互的技巧,需要的朋友可以参考下

    本文实例讲述了python使用Queue在多个子进程间交换数据的方法,

python使用Queue在多个子进程间交换数据的方法

。分享给大家供大家参考。具体如下:

    这里将Queue作为中间通道进行数据传递,Queue是线程和进程安全的

   

from multiprocessing import Process, Queuedef f(q):  q.put([42, None, ‘hello‘])if __name__ == ‘__main__‘:  q = Queue()  p = Process(target=f, args=(q,))  p.start()  print q.get() # prints "[42, None, ‘hello‘]"  p.join()

    希望本文所述对大家的Python程序设计有所帮助,

电脑资料

python使用Queue在多个子进程间交换数据的方法》(http://meiwen.anslib.com)。

最新文章