multiprocessing in subpackage on windows

Darren Dale dsdale24 at gmail.com
Wed Apr 20 18:20:31 EDT 2011


I have two really simple scripts:

C:\Python27\Scripts\foo
---
if __name__ == '__main__':
    import bar
    bar.main()

C:\Python27\Lib\site-packages\bar.py
---
from multiprocessing import Pool

def task(arg):
    return arg

def main():
    pool = Pool()
    res = pool.apply_async(task, (3.14,))

    print res.get()

if __name__ == '__main__':
    main()


If I run "python C:\[...]bar.py", 3.14 is printed. If I run "python C:\
[...]foo", I get a long string of identical errors:

 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 455, in
prepare
     file, path_name, etc = imp.find_module(main_name, dirs)
ImportError: No module named foo


This same scheme works on Linux. What step have I missed to allow a
script to run code from a subpackage that uses multiprocessing?

Thanks,
Darren



More information about the Python-list mailing list