Mercurial > piecrust2
diff piecrust/commands/builtin/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 | d7a548ebcd58 |
children | c2ca72fb7f0b |
line wrap: on
line diff
--- a/piecrust/commands/builtin/serving.py Tue Feb 03 18:50:58 2015 -0800 +++ b/piecrust/commands/builtin/serving.py Tue Feb 03 18:51:30 2015 -0800 @@ -1,5 +1,5 @@ import logging -from piecrust.serving import Server +from piecrust.serving import Server, _sse_abort from piecrust.commands.base import ChefCommand @@ -48,10 +48,13 @@ if ctx.args.wsgi == 'werkzeug': from werkzeug.serving import run_simple - run_simple(host, port, app, - threaded=True, - use_debugger=debug, - use_reloader=ctx.args.use_reloader) + try: + run_simple(host, port, app, + threaded=True, + use_debugger=debug, + use_reloader=ctx.args.use_reloader) + finally: + _sse_abort.set() elif ctx.args.wsgi == 'gunicorn': from gunicorn.app.base import BaseApplication