I\'m trying to implement multiprocessing to speed up a replication loop, but cannot get it to work in Python27. This is a very simplified version of my program, based on the
The problem is solved by adding a main() function as:
import itertools
from multiprocessing import Pool
def func(g, h, i):
return g + h + i
def helper(args):
args2 = args[0] + (args[1],)
return func(*args2)
def main():
pool = Pool(processes=4)
result = pool.map(helper,itertools.izip(itertools.repeat((2, 3)), range(10)))
print result
if __name__ == '__main__':
main()
Based on the answer from @ErikAllik I'm thinking that this might be a Windows-specific problem.
edit: Here is a clear and informative tutorial on multiprocessing in python.