Couldn't stop a running server via Ctrl-C

427 views
Skip to first unread message

Zap

unread,
Sep 10, 2008, 10:12:14 AM9/10/08
to cherrypy-users
Hello!

After updating from cp 3.0.3 to 3.1final I have the problem that I
couldn't stop a running Server by pressing Ctrl-C
when I start the server this way:

import cherrypy

class HelloWorld(object):
def index(self):
return "Hello World!"
index.exposed = True

if 0:
# ctrl-c works fine
cherrypy.quickstart(HelloWorld())
else:
# ctrl-c doesn't work
cherrypy.tree.mount(HelloWorld())
cherrypy.engine.start()
cherrypy.engine.block()

I couldn't find a hint in the tutorial or UpgradeTo31.

What is the right way to start a server via engine.start() ?

Thank you very much.
Zap

Robert Brewer

unread,
Sep 10, 2008, 11:53:15 AM9/10/08
to cherryp...@googlegroups.com

Subscribe either a signal handler (Unix) or a console control handler
(Windows). Here's quickstart in full:

def quickstart(root=None, script_name="", config=None):
if config:
_global_conf_alias.update(config)

if root is not None:
tree.mount(root, script_name, config)

if hasattr(engine, "signal_handler"):
engine.signal_handler.subscribe()
if hasattr(engine, "console_control_handler"):
engine.console_control_handler.subscribe()

engine.start()
engine.block()

Robert Brewer
fuma...@aminus.org

Reply all
Reply to author
Forward
0 new messages