I've discovered that when I start a CherryPy server with sudo, then try to terminate it by pressing Ctrl-C, it sometimes (~1/3 of the time) hangs. I can reproduce this using the CherryPy hello world:
import cherrypy
class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True
cherrypy.quickstart(HelloWorld())
The output I see is:
$ 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>
This is an issue for me because I would like to run my server on port 80, and I have some stuff going on in other threads that should be cleaned up properly. I guess it's mostly just a nuisance for debugging, but I am curious nonetheless.
I opened an issue regarding this with CherryPy. Turns out that the issue was the version of sudo that I was using (1.7.4):
https://bitbucket.org/cherrypy/cherrypy/issue/1186/sometimes-hangs-when-running-with-sudo-and
I retested with the latest (1.8.6p3) and do not have this issue anymore. Thanks to Chris Beelby!