This is a generic package for parallelization using Threads and Processes
- pip install plmap
- Download the source : git clone https://github.com/brlohith/parallelization.git
- cd parallelization
- python setup.py install
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> , ..... ]