Terry J. Reedy <tjre...@udel.edu> added the comment: After looking at the doc chapter, I get that 'if __name__' block is needed on Windows.
OK. batch mode with if __name__ block: testmp.py --------- print('Top of Module') class C: def f(s): print('Method C.f') if __name__ == '__main__': print('Start of main block') import multiprocessing p = multiprocessing.Process(target=C.f, args=(C(),)) p.start() p.join() command-prompt..\python32> python @misc2\testmp.py output (similar to that of OP): Top of Module Start of main block Traceback (most recent call last): File "C:\Programs\Python32\lib\pickle.py", line 679, in save_global klass = getattr(mod, name) AttributeError: 'module' object has no attribute 'f' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "@misc2\testmp.py", line 9, in <module> p.start() File "C:\Programs\Python32\lib\multiprocessing\process.py", line 130, in start self._popen = Popen(self) File "C:\Programs\Python32\lib\multiprocessing\forking.py", line 267, in __init__ dump(process_obj, to_child, HIGHEST_PROTOCOL) File "C:\Programs\Python32\lib\multiprocessing\forking.py", line 190, in dump ForkingPickler(file, protocol).dump(obj) File "C:\Programs\Python32\lib\pickle.py", line 237, in dump self.save(obj) File "C:\Programs\Python32\lib\pickle.py", line 344, in save self.save_reduce(obj=obj, *rv) File "C:\Programs\Python32\lib\pickle.py", line 432, in save_reduce save(state) File "C:\Programs\Python32\lib\pickle.py", line 299, in save f(self, obj) # Call unbound method with explicit self File "C:\Programs\Python32\lib\pickle.py", line 623, in save_dict self._batch_setitems(obj.items()) File "C:\Programs\Python32\lib\pickle.py", line 656, in batch_setitems save(v) File "C:\Programs\Python32\lib\pickle.py", line 299, in save f(self, obj) # Call unbound method with explicit self File "C:\Programs\Python32\lib\pickle.py", line 683, in save_global (obj, module, name)) _pickle.PicklingError: Can't pickle <function f at 0x00B4B4B0>: it's not found as __main__.f C:\Programs\Python32>Top of Module Traceback (most recent call last): File "<string>", line 1, in <module> File "C:\Programs\Python32\lib\multiprocessing\forking.py", line 370, in main self = load(from_parent) EOFError The essential problem seems to be the attempt to pickle the method attribute of the class as a class attribute of the module. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue11969> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com