Cannot use multiprocessing and zip together on windows

Leo Jay python.leojay at gmail.com
Mon Dec 12 02:07:48 EST 2011


Hi All,

I have a file p.zip, there is a __main__.py in it, and the content of
__main__.py is:

from multiprocessing import Process
import os

def f():
   print 'in f, pid:', os.getpid()

if __name__ == '__main__':
   print 'pid:', os.getpid()
   p = Process(target=f)
   p.start()
   p.join()


On linux, I can get expected result for running "python p.zip"
But on windows xp, I got:

Traceback (most recent call last):
 File "<string>", line 1, in <module>
 File "C:\python27\lib\multiprocessing\forking.py", line 346, in main
   prepare(preparation_data)
 File "C:\python27\lib\multiprocessing\forking.py", line 454, in prepare
   assert main_name not in sys.modules, main_name
AssertionError: __main__

It seems that the situation described here is similar:
http://bugs.python.org/issue10128

But the patch doesn't work for me.

Anybody knows how to fix this?
Thanks.

-- 
Best Regards,
Leo Jay



More information about the Python-list mailing list