我有以下代码test.py:
#multiprocessing in the interactive Python
import time
from multiprocessing import Process, Pipe
def MyProcess(a):
while(1):
time.sleep(1)
a.send("tic")
if __name__ == "__main__":
a, b = Pipe()
p = Process(target=MyProcess, args=(a,))
p.start()
while(1):
msg=b.recv()
print(msg)
如果我在DOS shell“python test.py”中执行它,它工作正常
但是如果我使用IEP(Pyzo)的“执行文件”,它就不起作用.
Traceback (most recent call last):
File "", line 1, in
File "C:\pyzo2014a_64b\lib\multiprocessing\spawn.py", line 106, in spawn_main
exitcode = _main(fd)
File "C:\pyzo2014a_64b\lib\multiprocessing\spawn.py", line 116, in _main
self = pickle.load(from_parent)
AttributeError: Can't get attribute 'MyProcess' on
我发现这是一个记录在案的“问题”.请检查以下链接的答案.
这是否意味着我不应该使用交互式Python中的多处理包?这是否意味着我无法从IPython控制台创建进程?
对此的任何澄清将受到高度赞赏