I'm using the multiprocessing package in order parallelize a program. Now I have an issue on this tutorial with the following code:
def howmany_within_range(row, minimum, maximum):
"""Returns how many numbers lie within `maximum` and `minimum` in a given `row`"""
count = 0
for n in row:
if minimum <= n <= maximum:
count = count + 1
return count
np.random.RandomState(100)
arr = np.random.randint(0, 10, size=[200000, 5])
data = arr.tolist()
pool = mp.Pool(5)
results = [pool.apply(howmany_within_range, args=(row, 4, 8)) for row in data]
pool.close()
print(results[:10])
I try to run with Anaconda but the program stuck then I try to run on Qt console and I get this error: module 'main' has no attribute 'spec' There is a way to run this program?