def _yield_app(global_conf, app_conf, test_conf, web): # Yield either wsgi webapp of the underlying pulsar # app object if the web layer is not needed. try: if web: from pulsar.web.wsgi import app_factory app = app_factory(global_conf, **app_conf) yield TestApp(app, **test_conf) else: from pulsar.main import load_app_configuration from pulsar.core import PulsarApp app_conf = load_app_configuration(local_conf=app_conf) app = PulsarApp(**app_conf) yield app finally: try: shutdown_args = [] if not web: shutdown_args.append(2) app.shutdown(*shutdown_args) except Exception: pass
def init_webapp(**config_kwds): app_conf = load_app_configuration(**config_kwds) pulsar_app = PulsarApp(**app_conf) webapp = PulsarWebApp(pulsar_app=pulsar_app) atexit.register(webapp.shutdown) return webapp