view foodtruck/main.py @ 600:c37307a72f79

admin: Fix constructor for Mercurial SCM.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 24 Jan 2016 10:41:36 -0800
parents d7baac1d01e6
children c6bc0ef03f82
line wrap: on
line source

import logging


logger = logging.getLogger(__name__)


def run_foodtruck(debug=False):
    if debug:
        import foodtruck.settings
        foodtruck.settings.DEBUG = debug

    from .web import app
    try:
        app.run(debug=debug, threaded=True)
    except SystemExit:
        # This is needed for Werkzeug's code reloader to be able to correctly
        # shutdown the child process in order to restart it (otherwise, SSE
        # generators will keep it alive).
        from .views import baking
        logger.debug("Shutting down SSE generators from main...")
        baking.server_shutdown = True
        raise