I took the example from senderle here. I thought I had copy and pasted the main parts of the code, but my code will not stop.
I've tried this example after my own attempts at solving a different problem using pool.map
kept hanging. I wonder if there's something actually wrong with the code or my multiprocessing package ...
Below is the code I pulled from senderle's top answer:
from itertools import product
import multiprocessing
def merge_names(a, b):
return '{} & {}'.format(a, b)
names = ['Brown', 'Wilson', 'Bartlett', 'Rivera', 'Molloy', 'Opie']
with multiprocessing.Pool(processes=3) as pool:
results = pool.starmap(merge_names, product(names, repeat=2))
print(results)
I was expecting a list of 36 'merged' names, but the process keeps running without end. Any help?