Created
November 16, 2022 19:02
-
-
Save sheenobu/064b501b76415c6f6dacb6afa1ac6305 to your computer and use it in GitHub Desktop.
asgi middleware for https://github.com/prometheus/client_python/issues/855
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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