有以下简单的代码:
原文链接:https://www.f2er.com/windows/371992.htmlfrom multiprocessing import Process,freeze_support def foo(): print 'hello' if __name__ == '__main__': freeze_support() p = Process(target=foo) p.start()
它在使用Python 3.3的Linux或Windows上运行良好,但在使用Python 2.7的Windows上运行失败.
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: thread
一般来说,我试过的所有多处理示例都失败了.为什么?