Skip to content

Instantly share code, notes, and snippets.

@joshthecoder
Created November 3, 2009 05:54
Show Gist options
  • Save joshthecoder/224833 to your computer and use it in GitHub Desktop.
Save joshthecoder/224833 to your computer and use it in GitHub Desktop.
diff --git a/bottle.py b/bottle.py
index 48ceea4..ddf7ad4 100644
--- a/bottle.py
+++ b/bottle.py
@@ -608,6 +608,9 @@ class ServerAdapter(WSGIAdapter):
def __repr__(self):
return "%s (%s:%d)" % (self.__class__.__name__, self.host, self.port)
+ def stop(self):
+ return
+
class WSGIRefServer(ServerAdapter):
def run(self, handler):
@@ -619,8 +622,11 @@ class WSGIRefServer(ServerAdapter):
class CherryPyServer(ServerAdapter):
def run(self, handler):
from cherrypy import wsgiserver
- server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler)
- server.start()
+ self.server = wsgiserver.CherryPyWSGIServer((self.host, self.port), handler)
+ self.server.start()
+
+ def stop(self):
+ self.server.stop()
class FlupServer(ServerAdapter):
@@ -690,6 +696,7 @@ def run(app=None, server=WSGIRefServer, host='127.0.0.1', port=8080,
except KeyboardInterrupt:
if not quiet: # pragma: no cover
print "Shutting Down..."
+ server.stop()
#TODO: If the parent process is killed (with SIGTERM) the childs survive...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment