python - 如何关闭 cherrypy 服务器?

标签 python cherrypy

我在 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/

相关文章:

python - pip 在错误的 python 版本下安装 python 库

python - 如何允许在 CherryPy 中下载动态创建的文件?

python - 导入错误 : No module named mapnik (Ubuntu 10. 10)

python - The Foundry Nuke – 在 QLabel 上显示动画值

python - 有没有办法检索当前选择的 conda 环境和/或在其中执行命令?

python - 如何在 CherryPy 中为 WTForms 集成验证码 (Recaptcha)

python - 如何保持愉快的 session 彼此不同

nginx - 樱桃 : Do I really need to put it behind a frontend?

python - 如何查看安装另一个包需要哪些包?

python - python中Json的点符号