Skip to content

ASGI lifespan crash #855

Open
sheenobu/client_python
#1
@sheenobu

Description

@sheenobu

client_python version: testing on 0.15.0 but the offending code exists in the master branch as well.

I'm trying to use the prometheus ASGI handler with Hypercorns DispatcherMiddleware. It sends lifecycle events which are not properly handled:

def make_asgi_app(registry: CollectorRegistry = REGISTRY, disable_compression: bool = False) -> Callable:
    """Create a ASGI app which serves the metrics from a registry."""

    async def prometheus_app(scope, receive, send):
        assert scope.get("type") == "http"
        # Prepare parameters

assert scope.get("type") == "http" ensures any ASGI middleware sending lifecycle events will fail to start the prometheus asgi app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions