Почему ThreadPoolExecutor работает, а ProcessPoolExecutor - нет? (Раскрыты) - PullRequest
0 голосов
/ 30 марта 2020

Я изучаю Threading и Multiprocessing в Python 3. Я попробовал простую Программу, которая работала с ThreadPoolExecutor, но когда я перешел на ProcessPoolExecutor, он не выполнил ни один из приведенных кодов.

from PIL import Image
from PIL import ImageFilter
import os

directory = r'C:\Users\admin\OneDrive\Pictures\My Photos'
imgs_file = []


for img_file in os.listdir(directory):
    if (img_file.endswith(".JPG") or img_file.endswith(".jpg")):
        imgs_file.append(img_file)

def image_filter(image_file):
    img = Image.open(image_file)
    img= img.filter(ImageFilter.GaussianBlur(radius = 9))
    img.save(f'Converted {image_file}')  

import concurrent.futures
with concurrent.futures.ProcessPoolExecutor() as p:
    p.map(image_filter, imgs_file)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...