From a46a4b17075f42742a7e9063581e2135d4d49db2 Mon Sep 17 00:00:00 2001 From: Ryan Kelly Date: Fri, 28 Jan 2011 10:21:42 +1100 Subject: [PATCH] cleanly interrupt server when we get SIGTERM --- m2wsgi/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/m2wsgi/__init__.py b/m2wsgi/__init__.py index 55eb288..0d92b0c 100644 --- a/m2wsgi/__init__.py +++ b/m2wsgi/__init__.py @@ -191,7 +191,9 @@ def main(argv=None): iomod.monkey_patch() # Try hard to clean up properly when killed if signal is not None: - signal.signal(signal.SIGTERM,lambda *a: sys.exit(1)) + def interrupt(): + raise KeyboardInterrupt + signal.signal(signal.SIGTERM,lambda *a: interrupt) # Start the requested N handler threads. # N-1 are started in background threads, then one on this thread. handlers = []