首页 > 解决方案 > 多处理管理器列表错误没有这样的文件或目录,尽管没有让管理器服务器死机

问题描述

我正在遵循这些 stackoverflow 问题[1] [2]的建议。我在不同的模块中有我的多处理功能。我从主要调用它。目标是从多个进程中读取图像。我等待所有的孩子完成并加入。我正在使用 Ubuntu 18.04。对此进行调试的任何建议表示赞赏。

编辑:这是完整的堆栈跟踪

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 749, in _callmethod
    conn = self._tls.connection
AttributeError: 'ForkAwareLocal' object has no attribute 'connection'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 98, in <module>
    input_transforms, model)
  File "/home/user/visualize_model/src/utils.py", line 126, in create_embedding_parallel
    input_images = list(input_images)
  File "<string>", line 2, in __len__
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 753, in _callmethod
    self._connect()
  File "/usr/local/lib/python3.6/multiprocessing/managers.py", line 740, in _connect
    conn = self._Client(self._token.address, authkey=self._authkey)
  File "/usr/local/lib/python3.6/multiprocessing/connection.py", line 487, in Client
    c = SocketClient(address)
  File "/usr/local/lib/python3.6/multiprocessing/connection.py", line 614, in SocketClient
    s.connect(address)
FileNotFoundError: [Errno 2] No such file or directory

主文件

from utils import create_embeddings

if __name__ == "__main__":
    embeddings = utils.create_embeddings(folder, num_frames)
    # more statements follow after this

实用程序.py

from PIL import Image
import os
import multiprocessing as mp

def f(image_list, folder, index):
    image_path = os.path.join(folder, "images{:04d}.png".format(index))
    image_list.append(Image.open(image_path))

def create_embeddings(folder, num_frames):

    with mp.Manager() as manager:
        image_list = manager.list()
        processes = []
        for index in range(num_frames):
            p = mp.Process(target=f, args=(image_list, folder, index))
            p.start()
            processes.append(p)
        for p in processes:
            p.join()
        
    return image_list

标签: pythonmultiprocessingpython-imaging-library

解决方案


推荐阅读