Tests: added ASGI Lifespan.

This commit is contained in:
Andrei Zeliankou
2020-10-05 11:05:00 +01:00
parent 9d8d2c1758
commit 152ad526f4
5 changed files with 114 additions and 0 deletions

View File

@@ -0,0 +1,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