我发现当我用sudo启动CherryPy服务器时,然后按Ctrl-C尝试终止它,它有时会(〜1/3的时间)挂起。我可以使用CherryPy hello world重现这个:
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.quickstart(HelloWorld())
我看到的输出是:
$ sudo python hello.py
[23/Nov/2012:21:23:03] ENGINE Listening for SIGHUP.
[23/Nov/2012:21:23:03] ENGINE Listening for SIGTERM.
[23/Nov/2012:21:23:03] ENGINE Listening for SIGUSR1.
[23/Nov/2012:21:23:03] ENGINE Bus STARTING
CherryPy Checker:
The Application mounted at '' has an empty config.
[23/Nov/2012:21:23:03] ENGINE Started monitor thread 'Autoreloader'.
[23/Nov/2012:21:23:03] ENGINE Started monitor thread '_TimeoutMonitor'.
[23/Nov/2012:21:23:04] ENGINE Serving on 127.0.0.1:8080
[23/Nov/2012:21:23:04] ENGINE Bus STARTED
^CTraceback (most recent call last):
File "hello.py", line 7, in <module>
cherrypy.quickstart(HelloWorld())
File "/usr/local/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/__init__.py", line 161, in quickstart
engine.block()
File "/usr/local/lib/python2.7/site-packages/CherryPy-3.2.2-py2.7.egg/cherrypy/process/wspbus.py", line 303, in block
except (KeyboardInterrupt, IOError):
KeyboardInterrupt
<No subsequent command prompt>
这对我来说是一个问题因为我想在端口80上运行我的服务器,并且我在其他线程中有一些应该正确清理的东西。我想这主要是调试的麻烦,但我很好奇。
答案 0 :(得分:0)
我用CherryPy解决了这个问题。事实证明问题是我正在使用的sudo版本(1.7.4):
https://bitbucket.org/cherrypy/cherrypy/issue/1186/sometimes-hangs-when-running-with-sudo-and
我重新测试了最新的(1.8.6p3)并且不再有这个问题了。感谢Chris Beelby!