Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Development HTTP server not stopped when raising SystemExit #100

hdemers opened this Issue · 3 comments

2 participants


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?


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 referenced this issue from a commit in Irfy/webpy
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.