summaryrefslogblamecommitdiffhomepage
path: root/test/python/lifespan/failed/asgi.py
blob: 8f315f70ef69159d5f2db80d3927d1564aa63dd7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11










                                                                  
async def application(scope, receive, send):
    if scope['type'] == 'lifespan':
        while True:
            message = await receive()
            if message['type'] == 'lifespan.startup':
                await send({"type": "lifespan.startup.failed"})
                raise Exception('Exception blah')

            elif message['type'] == 'lifespan.shutdown':
                await send({'type': 'lifespan.shutdown.complete'})
                return