python使用Queue在多个子进程间交换数据的方法,pythonqueue
python使用Queue在多个子进程间交换数据的方法,pythonqueue
本文实例讲述了python使用Queue在多个子进程间交换数据的方法。分享给大家供大家参考。具体如下:
这里将Queue作为中间通道进行数据传递,Queue是线程和进程安全的
from multiprocessing import Process, Queue def 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关闭windows进程的方法,pythonwindows进程
- python开启多个子进程并行运行的方法,python个子
- python对指定目录下文件进行批量重命名的方法,
- python使用multiprocessing模块实现带回调函数的异步调用方
- python使用装饰器和线程限制函数执行时间的方法,pyt
- python使用7z解压apk包的方法,python7z解压apk
- 在Docker上开始部署Python应用的教程,dockerpython
- 用Python的Django框架编写从Google Adsense中获得报表的应用
- 使用Python的Scrapy框架编写web爬虫的简单示例,pythonscr
- 使用Python脚本在Linux下实现部分Bash Shell的教程,python
评论关闭