我发现当我使用 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 上运行我的服务器,并且我在其他线程中发生了一些应该正确清理的事情。我想这主要是调试的麻烦,但我还是很好奇。