"""Real applications used by the supervisor process tests."""
import asyncio
import os
import time
async def app(scope, receive, send):
if scope['path'] == '/crash':
os._exit(71)
if scope['path'] == '/hang':
time.sleep(30)
if scope['path'] == '/slow':
await asyncio.sleep(0.6)
await send({'type': 'http.response.start', 'status': 200})
await send({'type': 'http.response.body', 'body': str(os.getpid()).encode()})
def factory():
async def application(scope, receive, send):
await send({'type': 'http.response.start', 'status': 200})
await send({'type': 'http.response.body', 'body': ('factory:' + str(os.getpid())).encode()})
return application