python使用Queue在多个子进程间交换数据的方法
作者:work24 时间:2023-07-26 04:56:50
本文实例讲述了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,Queue,进程
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
学ASP应该注意ASP程序书写的规范标准
2008-10-17 10:16:00
pytorch 实现冻结部分参数训练另一部分
2023-06-14 16:43:10
python类共享变量操作
2021-10-21 02:16:32
![](https://img.aspxhome.com/file/2023/6/112426_0s.jpg)
Django多层嵌套ManyToMany字段ORM操作详解
2023-07-01 02:26:28
python中urllib.unquote乱码的原因与解决方法
2023-08-24 14:56:43
对Python 字典元素进行删除的方法
2021-07-03 00:27:50
python scrapy框架中Request对象和Response对象的介绍
2021-04-02 07:29:59
![](https://img.aspxhome.com/file/2023/6/95326_0s.png)
Django实现一对多表模型的跨表查询方法
2022-04-09 01:53:33
Entity Framework使用Code First模式管理数据库
2024-01-28 04:40:43
![](https://img.aspxhome.com/file/2023/8/98138_0s.jpg)
Python解析并读取PDF文件内容的方法
2021-07-13 20:06:21
![](https://img.aspxhome.com/file/2023/0/100900_0s.png)
python通过re正则表达式切割中英文的操作
2021-11-29 04:41:23
Django values()和value_list()的使用
2021-08-21 23:03:12
![](https://img.aspxhome.com/file/2023/7/133287_0s.jpg)
Django 权限认证(根据不同的用户,设置不同的显示和访问权限)
2023-09-18 04:07:30
![](https://img.aspxhome.com/file/2023/9/114659_0s.png)
SQL语句学习
2024-01-18 15:07:00
python实现浪漫的烟花秀
2023-09-23 00:50:23
![](https://img.aspxhome.com/file/2023/5/65515_0s.png)
使用SpringBoot + Redis 实现接口限流的方式
2023-07-11 00:06:49
MSSQL 基本语法及实例操作语句
2024-01-28 10:29:59
master数据库损坏的解决办法有哪些
2024-01-16 16:30:06
asp如何获知并显示文件的大小?
2009-11-23 20:59:00
[翻译]标记语言和样式手册 Chapter 12 CSS布局
2008-02-13 14:19:00
![](https://img.aspxhome.com/file/UploadPic/20082/13/2008213144620374s.jpg)