Manager()通过python工作,但在cx_freeze构建环境中失败

时间:2014-03-07 07:38:48

标签: python python-2.7 multiprocessing cx-freeze

我在python多处理中遇到了这个奇怪的Manager()调用问题。当我通常通过shell调用我的程序时,一切都很好。但是用cx_freeze构建的同样的东西失败了。这是代码示例

from multiprocessing import Pipe, Manager, Queue
if conf.shared_dict == None:
    manager = Manager()
    conf.shared_dict = manager.dict()
    conf.shared_dict['seed'] = 0
parent_conn, child_conn= Pipe()

The failure happens in Manager() call and following is the stack trace.

File C:\Users\data-sync\service_api.py, line 93, in message_broker
    manager = Manager()
File C:\Python27\lib\multiprocessing\__init__.py, line 99, in Manager
    m.start()
File C:\Python27\lib\multiprocessing\managers.py, line 528, in start
    self.address = reader.recv()
EOFError

1 个答案:

答案 0 :(得分:1)

解决。我没有打电话

multiprocessing.freeze_support()

添加此内容后效果很好。