can't use multiprocessing with class factory?

Alan alan.isaac at gmail.com
Fri Jan 28 14:02:49 EST 2011


Can the below example be fixed to work?
Thanks,
Alan Isaac

import multiprocessing as mp

class Test(object):
    pass

def class_factory(x):
    class ConcreteTest(Test):
        _x = x
    return ConcreteTest

def f(cls):
    print cls._x

if __name__ == '__main__':
    pool = mp.Pool(2)
    pool.map(f, [class_factory(i) for i in range(4)])




More information about the Python-list mailing list