粗代码:
from multiprocessing import Process
def getPAprofilesPages():
#do stuff here
def getPBprofilesPages():
#do stuff here
P1 = Process(target = getPAprofilesPages, args = [] )
P2 = Process(target = getPBprofilesPages, args = [] )
注意,函数不带参数。
我尝试将args设置为None、()、(、)和[],如上所示,并且在初始化时完全忽略它。
在任何情况下,尝试在解释器中运行P1.start()
或P2.start()
时都会出现相同的错误:
>>> Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\******\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 105, in spawn_main
exitcode = _main(fd)
File "C:\Users\******\AppData\Local\Programs\Python\Python37\lib\multiprocessing\spawn.py", line 115, in _main
self = reduction.pickle.load(from_parent)
AttributeError: Can't get attribute 'getPAprofilesPages' on <module '__main__' (built-in)>
下面的代码在脚本中运行良好
但是,您说您正在解释器中运行它,这就是您的问题所在,因为您不能使用multiprocessing package in interactive Python。你知道吗
我知道这不是你想要的答案,但它解释了你的错误。您可以在该链接中阅读更多关于解决方法的内容。你知道吗
相关问题 更多 >
编程相关推荐