小编Joh*_*aki的帖子

Python 多处理:进程对象不可调用

所以,最近,我一直在试验多处理模块。我写了这个脚本来测试它:

from multiprocessing import Process
from time import sleep

def a(x):
    sleep(x)
    print ("goo")

a = Process(target=a(3))
b = Process(target=a(5))
c = Process(target=a(8))
d = Process(target=a(10))

if __name__ == "__main__":
    a.start()
    b.start()
    c.start()
    d.start()
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试运行它时,它会引发此错误:

goo
Traceback (most recent call last):
  File "C:\Users\Andrew Wong\Desktop\Python\test.py", line 9, in <module>
    b = Process(target=a(5))
TypeError: 'Process' object is not callable
Run Code Online (Sandbox Code Playgroud)

......我不知道发生了什么。有谁知道发生了什么,我该如何解决?

python multiprocessing python-multiprocessing

3
推荐指数
1
解决办法
6915
查看次数