import multiprocessing
import time
def worker():
n=5 #number of process
while n>0:
print("the time is {0}".format(time.ctime()))
time.sleep(2)
n-=1
if __name__=="__main__":
p=multiprocessing.Process(target=worker)
p.start()
print("end")
3.5.2 |Continuum Analytics, Inc.| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]
Python Type "help", "copyright", "credits" or "license" for more information.
[evaluate multiprocess.py]
end
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\Users\xxxxx\Miniconda3\lib\multiprocessing\spawn.py", line 106, in spawn_main
exitcode = _main(fd)
File "c:\Users\xxxx\Miniconda3\lib\multiprocessing\spawn.py", line 116, in _main
self = pickle.load(from_parent)
AttributeError: Can't get attribute 'worker' on <module '__mp_main__' from 'C:\\Program Files (x86)\\Wing IDE 101 5.1\\src\\debug\\tserver\\_sandbox.py'>
我真的不知道如何解决这个问题 一旦我使用多处理,将发生属性错误 错误消息总是显示AttributeError,无论我做什么