将共享对象添加到manager.Namespace

时间:2018-05-24 11:32:39

标签: python multiprocessing python-multiprocessing

This seems to be a python 3.6 bug

manager.Queue分配给manager.Namespace属性时,会获得TypeError。重现它很简单:

>>> from multiprocessing import Manager
>>> manager = Manager()
>>> np = manager.Namespace()
>>> np.shared_queue = manager.Queue()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\users\leonardo.schettini\appdata\local\programs\python\python36-32\Lib\multiprocessing\managers.py", line 1065, in __setattr__
    return callmethod('__setattr__', (key, value))
File "c:\users\leonardo.schettini\appdata\local\programs\python\python36-32\Lib\multiprocessing\managers.py", line 772, in _callmethod
    raise convert_to_error(kind, result)
multiprocessing.managers.RemoteError:
---------------------------------------------------------------------------
Traceback (most recent call last):
File "c:\users\leonardo.schettini\appdata\local\programs\python\python36-32\Lib\multiprocessing\managers.py", line 228, in serve_client
    request = recv()
File "c:\users\leonardo.schettini\appdata\local\programs\python\python36-32\Lib\multiprocessing\connection.py", line 251, in recv
    return _ForkingPickler.loads(buf.getbuffer())
File "c:\users\leonardo.schettini\appdata\local\programs\python\python36-32\Lib\multiprocessing\managers.py", line 881, in RebuildProxy
    return func(token, serializer, incref=incref, **kwds)
TypeError: AutoProxy() got an unexpected keyword argument 'manager_owned'
---------------------------------------------------------------------------

Here,我发现manager.Queue只是

  

指向由multiprocessing.Manager()对象管理的共享队列的地址(代理)

如果有人试图分配multiprocessing.Queue,则会引发RuntimeError。如果您认为multiprocessing.Queue无法被腌制(有关提供的链接的信息),这是有道理的

0 个答案:

没有答案