我在 win7 上,我启动了 helloworld.py 教程,一切正常,但我不知道如何退出该服务。我使用
quit()
但命令行给我一条错误消息并退出。但服务仍在运行并占用我的 8080 端口。我没有找到手动关闭它的方法。
File "C:\python32\lib\site-packages\cherrypy\process\wspbus.py", line 197, in
publish
output.append(listener(*args, **kwargs))
File "C:\python32\lib\site-packages\cherrypy\_cpserver.py", line 151, in start
ServerAdapter.start(self)
File "C:\python32\lib\site-packages\cherrypy\process\servers.py", line 167, in
start
wait_for_free_port(*self.bind_addr)
File "C:\python32\lib\site-packages\cherrypy\process\servers.py", line 410, in
wait_for_free_port
raise IOError("Port %r not free on %r" % (port, host))
IOError: Port 8080 not free on '0.0.0.0'
最佳答案
根据 this page , quit()
不适合这个任务。
根据您运行服务器的方式,您应该考虑使用 cherrypy.engine.exit
:
>>> help(cherrypy.engine.exit)
exit(self) method of cherrypy.process.win32.Win32Bus instance
Stop all services and prepare to exit the process.
关于python - 如何关闭 cherrypy 服务器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12155930/