Hey, I struggle to "extend" a multiprocessing example to my problem with a itertools.product result iterator. How I have to assign the combos.next() elements approriate to Pool.imap/calc functions?
Thanks in advance Christian from multiprocessing import Process,Queue,Pool import Calculation import DataSimulation from itertools import product def produce_example_combos(size=6,na=1000,nb=10): data = DataSimulation.DataSimulation() a = [data.generate_simple(size) for x in xrange(na)] b = [data.generate_simple(size) for x in xrange(nb)] it = product(a,b) return it def calc(elements): calc.q.put("Doing:" + elements[0] + elements[1]) ratio = Calculation.ratio(elements[0],elements[1]) return ratio def calc_init(q): calc.q = q if __name__ == '__main__': combos = produce_example_combos() print "tesdata generated" q = Queue() p = Pool(10, calc_init, [q]) results = p.imap(calc,combos.next()) p.close() for i in combos: print q.get() print results.next() -- http://mail.python.org/mailman/listinfo/python-list