python - 多处理管理器列表错误没有这样的文件或目录,尽管没有让管理器服务器死机
问题描述
我正在遵循这些 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
解决方案
推荐阅读
- c# - 动态表达式不适用于动态对象
- sql - 将 Select 查询的结果存储在 sql 文件 PSQL 中以供稍后使用
- c# - 如何合并 ASP.Net Core 配置文件中的多个数组?
- swagger - 为 Swagger UI 生成带有 swashbuckle 的 Get 请求示例
- java - 在活动中显示转换后的文件
- c# - IdentiyServer4 – API 检查令牌是否已过期
- swift - CoreData - 使用执行和后台线程获取 NSManagedObject
- android - ANR:Context.startForegroundService() 没有调用 Service.startForeground(), InvisibleToUser
- python - python中的线性回归严重错误,回归线完全错误
- php - 将中缀表达式转换为弹性搜索查询