0

我正在尝试使用以下代码启动 web.py 服务器:

if __name__ == "__main__":
    p = Process(target=app.run) #starts the web.py server
    p.start()
    main() #starts a main listening loop for errors, testing and logging
    p.join()

在哪里

app = web.application(urls, globals()) #part of the web.py framework... starts the REST server

但我得到了这个例外:

Traceback (most recent call last):
File "apitest.py", line 90, in <module>
p = Process(target=app.run)
TypeError: this constructor takes no arguments

我在任何地方都用谷歌搜索过,但我找不到发生了什么……有人可以帮忙吗?

谢谢!

4

1 回答 1

1

正如 agf 在评论中所建议的那样,您的命名空间可能会相互踩踏,因此名称Process不是Process您认为的那样。要解决此问题,请将您导入的方式更改Process为更明确:

import multiprocessing

# ...all your other code...

p = multiprocessing.Process(target=app.run) # starts the web.py server
于 2014-09-18T20:01:20.047 回答