diff --git a/posthog/asgi.py b/posthog/asgi.py index 22912a0c7b76e..678645bb01d3b 100644 --- a/posthog/asgi.py +++ b/posthog/asgi.py @@ -1,8 +1,17 @@ import os from django.core.asgi import get_asgi_application +from django.http.response import HttpResponse os.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings") os.environ.setdefault("SERVER_GATEWAY_INTERFACE", "ASGI") -application = get_asgi_application() + +def lifetime_wrapper(func): + async def inner(scope, receive, send): + if scope["type"] != "http": + return HttpResponse(status=501) + return func(scope, receive, send) + + +application = lifetime_wrapper(get_asgi_application())