Development HTTP server not stopped when raising SystemExit #100

hdemers opened this Issue Sep 23, 2011 · 3 comments


None yet

2 participants

hdemers commented Sep 23, 2011

In file, function runsimple, the exception SystemExit is not caught alongside KeyboardInterrupt. By catching SystemExit, the dev server would behave more like the production server.


Do you mean calling server.stop() so that it can close all the open sockets etc?

hdemers commented Oct 21, 2011

Well, server.stop() is already called on line 154 of file

However, SystemExit is not caught alongside KeyboardInterrupt on line 153. It would be good to catch that exception there, so the server is stopped when sys.exit is called.

@Irfy Irfy added a commit to Irfy/webpy that referenced this issue Dec 16, 2011
@Irfy Irfy Make applications stoppable in stand-alone mode applications typically run in WSGI mode, but when used in embedded
environments, it may be more useful to run the application in stand-alone
server mode (a.k.a. '').

Also, running the application via '' in a different thread kills
the out-of-the-box behavior of stopping the application with Ctrl-C.

This patch adds the 'stop(self)' method to the application class, so that
applications running stand-alone can be stopped easily with 'app.stop()'.

Credits: llc at stackoverflow:

Related to: #100

sys.exit is working now. I think it is good enough.

Here is an example with /shutdown.

import web
import sys

urls = (
    "/", "hello",
    "/shutdown", "shutdown",
app = web.application(urls, globals())

class hello:
    def GET(self):
        return "hello word"

class shutdown:
    def GET(self):

if __name__ == "__main__":
@anandology anandology closed this May 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment