示例#1
0
文件: auto.py 项目: vpistis/uvicorn
def LifespanAuto(config):
    if not config.loaded:
        config.load()

    try:
        config.loaded_app({"type": "lifespan"})
    except BaseException as exc:
        config.logger_instance.debug(
            "Lifespan protocol is not recognized by the application.")
        return LifespanOff(config)
    else:
        return LifespanOn(config)
示例#2
0
    async def test():
        config = Config(app=app, lifespan="off")
        lifespan = LifespanOff(config)

        await lifespan.startup()
        await lifespan.shutdown()