I'm processing a list of dictionaries in python like so:
def process_results(list_of_dicts):
first_result, second_result, count = [], [], 0
for dictionary in list_of_dicts:
first_result.append(dictionary)
if 'pi' in dictionary:
second_result.append(dictionary)
count += 1
print second_result, first_result
Next, via this simple SO example of using multiprocessing in a for loop, I'm trying the following (to completely erroneous results):
from multiprocessing import Pool
def process_results(list_of_dicts):
first_result, second_result, count = [], [], 0
for dictionary in list_of_dicts:
first_result.append(dictionary)
if 'pi' in dictionary:
second_result.append(dictionary)
count += 1
return second_result, first_result
if __name__ == '__main__':
list_of_dictionaries = # a list of dictionaries
pool = Pool()
print pool.map(process_results, list_of_dictionaries)
Why is this wrong? An illustrative example would be nice.