Multi Threading and Multi Processing made easy in Python2.7
This is a generic package for parallelization using Threads and Processes
def add(a, b): # Function to be called parallely
return a + b
input = [ [2, 3], [4, 5], [10, 11] ] # Set of inputs to the add function
Parallelization using Multi-Threading
from plmap import plmapt
errors, outputs = plmapt(add, input, [], 3, None)
errors : [('0', 'None'), ('0', 'None'), ('0', 'None')]
# [ ('<error_code>', '<error_description>') ..... ]
outputs : [5, 9, 21]
# [ <output for the first set of inputs>, <output for the second set of inputs> , ..... ]
Parallelization using Multi-Processing
from plmap import plmapp
errors, outputs = plmapp(add, input, [], 3, None)
errors : [('0', 'None'), ('0', 'None'), ('0', 'None')]
# [ ('<error_code>', '<error_description>') ..... ]
outputs : [5, 9, 21]
# [ <output for the first set of inputs>, <output for the second set of inputs> , ..... ]