Skip to content

Instantly share code, notes, and snippets.

@sheenobu
Created November 16, 2022 19:02
Show Gist options
  • Save sheenobu/064b501b76415c6f6dacb6afa1ac6305 to your computer and use it in GitHub Desktop.
Save sheenobu/064b501b76415c6f6dacb6afa1ac6305 to your computer and use it in GitHub Desktop.
def strip_lifespan_events(app):
"""
handlers/ignores lifespan events from being routed to the given app.
"""
async def _app(scope, receive, send):
if scope.get("type") == "lifespan":
payload = await receive()
await send({'type': payload['type'] + ".complete"})
return
await app(scope, receive, send)
return _app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment