I am trying to learn how to incorporate multiprocessing capabilities into my Python code. After reading through the documentation and several tutorials, I think I have an understanding of what my code should look like. I just want to be sure that I am not leaving out something important:
from multiprocessing import Pool
def job(args):
"""Your job function"""
if __name__ == '__main__':
# Sets up a process pool. Defaults to number of cores.
# Each input gets passed to job and processed in a separate process.
inputs = [
'file_1.txt',
'file_2.txt',
'file_3.txt'
]
Pool().map(job, inputs)