On Fri, Jan 28, 2011 at 20:02, Alan <alan.is...@gmail.com> wrote: > 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)])
Only classes defined on the top level of a module are picklable (see http://docs.python.org/dev/py3k/library/pickle#what-can-be-pickled-and-unpickled ). The collections.namedtuple class factory function works around this limitation by setting the __module__ attribute of the created class, but I'm not sure if this solution can be used in this case. Daniel -- http://mail.python.org/mailman/listinfo/python-list