python中multiprocessing.Manger()支持类型
2018-04-02 10:26
387 查看
1.作用
multiprocessing.Manger() 用于多进程间共享变量
2.支持存储类型‘
Manager支持的类型有list,dict,Namespace,Lock,RLock,Semaphore,BoundedSemaphore,Condition,Event,Queue,Value和Array。
from multiprocessing import Process,Manager
def foo(i,dic):
dic[i] = 100+i
print(dic.values())
if __name__ == '__main__':
manage = Manager()
dic = manage.dict() #如果用list,就是manage.list()
for i in range(10):
p = Process(target=foo,args=(i,dic))
p.start()
p.join()
multiprocessing.Manger() 用于多进程间共享变量
2.支持存储类型‘
Manager支持的类型有list,dict,Namespace,Lock,RLock,Semaphore,BoundedSemaphore,Condition,Event,Queue,Value和Array。
from multiprocessing import Process,Manager
def foo(i,dic):
dic[i] = 100+i
print(dic.values())
if __name__ == '__main__':
manage = Manager()
dic = manage.dict() #如果用list,就是manage.list()
for i in range(10):
p = Process(target=foo,args=(i,dic))
p.start()
p.join()
相关文章推荐
- 【原创】C++链表如何像Python List一样支持多种数据类型
- 让Boost.python支持Boost::any类型。
- mypy 支持静态类型编程的python变种
- Python中各个类型的支持操作
- 004_019 Python 用一条语句完成赋值和测试 如 while(a=fun()) 用于转化支持这种类型的代码的时候
- python整理二十四——让simplejson支持datetime类型的序列化
- 利用标准库fractions模块让Python支持分数类型的方法详解
- python不支持的类型
- Python不支持的类型
- [Python模块学习]使用标准库fractions模块使Python支持分数类型
- python 六个标准类型都支持哪些运算符?
- [导入]让Boost.python支持Boost::any类型。
- coreseek python数据源支持的字段类型
- Python变量和对象类型速记手册
- python中的基本数据类型
- python 数据类型总结之列表(二(3))
- Python元组类型
- debian apache 支持python
- Python内置数据类型
- Python基本数据类型之set