python網絡編程 windows下的multiprocessing模塊創建進程出現AttributeError: Can't get attribute 'fun' on 錯誤


 

【ipython錯誤】

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "d:\software\python\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "d:\software\python\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
AttributeError: Can't get attribute 'fun' on <module '__main__' (built-in)>
這是父進程
parent a: 1

本地IDE錯誤
RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

【解決辦法】  
  將執行代碼放在 if __name__ == "__main__":后,
  詳見上篇隨筆https://www.cnblogs.com/longyuu/p/14247847.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM