Python 从ThreadPoolExecutor返回与摘要iterable的顺序匹配的列表

Python 从ThreadPoolExecutor返回与摘要iterable的顺序匹配的列表,python,python-3.x,multithreading,image-processing,concurrency,Python,Python 3.x,Multithreading,Image Processing,Concurrency,是否可以从ThreadPoolExecutor返回一个与摘要iterable的顺序匹配的列表 我是图像处理,想要一个新转换图像的列表,其顺序与executor.map消化的顺序相同。请注意,我对任何想法都持开放态度。这是密码 img_list = [img1.png, img2.png, img3.png, img4.png, img5.png, img6.png] def img_to_jpeg(self, image): self.converted_jpeg_images =

是否可以从ThreadPoolExecutor返回一个与摘要iterable的顺序匹配的列表

我是图像处理,想要一个新转换图像的列表,其顺序与executor.map消化的顺序相同。请注意,我对任何想法都持开放态度。这是密码

img_list = [img1.png, img2.png, img3.png, img4.png, img5.png, img6.png]

def img_to_jpeg(self, image):
     self.converted_jpeg_images = []   

     im = image.open(image)
     im = im.convert('RGB')
     uuid = uuid4()

     fp2 = os.path.join(r"C:\Users\username\documents",
                           '{}.jpeg'.format(uuid))
     im.save(fp2, format='jpeg', quality=25)
     self.converted_jpeg_images.append(fp2)

     return fp2

with concurrent.futures.ThreadPoolExecutor() as executor:
     results = executor.map(self.img_to_jpeg, final_path_list)


当前,self.converted_jpeg_images列表将以映射进程完成操作的随机顺序附加新文件名

但是,我希望self.converted_jpeg_图像列表的顺序与img_列表的顺序相同

那么,如何使以下内容异步运行,但输出为:

img_list=[img1.png、img2.png、img3.png、img4.png、img5.png、img6.png]

自转换的\u jpeg\u图像=[img1.jpeg,img2.jpeg,img3.jpeg,img4.jpeg,img5.jpeg,img6.jpeg]