多重处理无法使用python打印结果

时间:2019-03-10 17:46:37

标签: python multiprocessing python-multiprocessing

我正在尝试将多重处理应用于功能。有打印功能,但未显示。

import json
import os
import multiprocessing as mp

def file_subreddit_comments(rfname):
    wfname = rfname + "_ext_com.txt"
    return wfname       

defaultFilePath = r'D:\Users\Jonathan\Desktop\Reddit Data\Run Comments\\'
directory = os.fsencode(defaultFilePath)

list_submission_id = []
submission_id_file = r'D:\Users\Jonathan\Desktop\Reddit Data\Manipulated Data-09-03-19-Final\UniqueIDSubmissionsList-09-03-2019.txt'
with open(submission_id_file, "r", encoding="utf8") as sif:
    for i, l in enumerate(sif):
        list_submission_id.append(l.rstrip())

new_submission_list_dir = []
for file in os.listdir(directory):
     filename = os.fsdecode(file)
     comment_path_read = defaultFilePath + filename
     new_submission_list_dir.append(comment_path_read)  

with mp.Pool(mp.cpu_count()-1) as p:
    results = p.map(file_subreddit_comments, [row for row in new_submission_list_dir])

print(results)

new_submission_list_dir包含要传递给功能file_subreddit_comments的所有文件的列表。我已经运行了一段时间的代码,但是print(results)

却没有打印任何内容

0 个答案:

没有答案