summaryrefslogtreecommitdiffhomepage
path: root/test/python/lifespan/failed/asgi.py
blob: fbd006f9c9735209a1e55178bec1bf832f0474b2 (plain) (blame)
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')

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