当读取用于库模块multiprocessing的文档时,它会多次说明__main__模块的重要性,包括条件(特别是在Windows中): #create Process() here
我的理解是,您不希望在模块的全局命名空间中创建Process()实例(因为当子进程导入模块时,他会无意中产生另一个)。只要我的Process()是在类方法中创建、管理和终止的,甚至是函数闭包,只是不是在top
我有一个简单的函数,我打算使用Python多处理模块并行运行。但是,我得到了以下错误RuntimeError: An attempt has been made to start a new process before the current process hasp1 = multiprocessing.Process(target=do_something)p1def main():
p1 =