view foodtruck/main.py @ 698:33ab9badfd7a

render: Change how we store render passes info. Previously we used a dictionary with integers as keys, which doesn't go well with JSON serialization. Now replace with an array of fixed length with items that are `None` by default.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 23 Mar 2016 16:39:22 -0700
parents 200c7063affa
children 3885421c29a3
line wrap: on
line source

import logging


logger = logging.getLogger(__name__)


def run_foodtruck(host=None, port=None, debug=False):
    if debug:
        import foodtruck.settings
        foodtruck.settings.DEBUG = debug

    from .web import app
    try:
        app.run(host=host, port=port, 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 . import pubutil
        logger.debug("Shutting down SSE generators from main...")
        pubutil.server_shutdown = True
        raise