这个错误是在使用多进程编程时出现的。它表示在当前进程完成引导阶段之前尝试启动新进程。

解决这个问题的方法是在主模块中使用以下习惯用法:

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

其中,freeze_support()是为了在程序被冻结为可执行文件时提供支持。如果程序不会被冻结为可执行文件,可以省略这一行。

在主模块中使用这个习惯用法可以确保在启动新进程之前完成引导阶段,避免出现这个错误。

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 st

原文地址: http://www.cveoy.top/t/topic/iXRc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录