I have a script that includes opening a file from a list and then doing something to the text within that file. I\'m using python multiprocessing and Pool to try to parallel
Maybe in this case you should use map_async:
import os
from multiprocessing import Pool
results = []
def testFunc(file):
message = ("Working in Process #%d" % (os.getpid()))
#This is just an illustration of some logic. This is not what I'm actually doing.
for line in file:
if 'dog' in line:
results.append(line)
return message
if __name__=="__main__":
print("saddsf")
p = Pool(processes=2)
files = ['/path/to/file1.txt', '/path/to/file2.txt']
results = p.map_async(testFunc, files)
print(results.get())