]> granicus.if.org Git - python/commitdiff
Make the ctl-C shutdown of serve.py prettier.
authorR. David Murray <rdmurray@bitdance.com>
Fri, 28 May 2010 18:17:20 +0000 (18:17 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Fri, 28 May 2010 18:17:20 +0000 (18:17 +0000)
Tools/scripts/serve.py

index b8d9cd73387d9607340cec000c58520b13b3d92b..50061d5ad3bd8c59775637210ebc59584702344d 100755 (executable)
@@ -28,5 +28,8 @@ if __name__ == '__main__':
     path = sys.argv[1]
     port = int(sys.argv[2]) if len(sys.argv) > 2 else 8000
     httpd = simple_server.make_server('', port, app)
-    print "Serving %s on port %s" % (path, port)
-    httpd.serve_forever()
+    print "Serving %s on port %s, control-C to stop" % (path, port)
+    try:
+        httpd.serve_forever()
+    except KeyboardInterrupt:
+        print "\b\bShutting down."