diff piecrust/serving.py @ 224:4f00bb99400e

serve: Fix exiting the server with `CTRL+C` when the SSE response is running.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 03 Feb 2015 18:51:30 -0800
parents 7decf00eee47
children a951cd4ef361
line wrap: on
line diff
--- a/piecrust/serving.py	Tue Feb 03 18:50:58 2015 -0800
+++ b/piecrust/serving.py	Tue Feb 03 18:51:30 2015 -0800
@@ -26,6 +26,9 @@
 logger = logging.getLogger(__name__)
 
 
+_sse_abort = threading.Event()
+
+
 class ServingEnvironment(StandardEnvironment):
     pass
 
@@ -446,6 +449,9 @@
                 yield bytes(outstr, 'utf8')
                 break
 
+            if _sse_abort.is_set():
+                break
+
             try:
                 logger.debug("Polling pipeline status queue...")
                 count += 1