Django-channels instance took too long to shut down and was killed

177 views Asked by At

can anyone tell me what could be the problem?

WARNING Application instance <Task pending name='Task-15' coro=<ProtocolTypeRouter.call() running at /usr/local/lib/python3.11/site-packages/channels/routing.py:62> wait_for=<Future pending cb=[_chain_future.._call_check_cancel() at /usr/local/lib/python3.11/asyncio/futures.py:387, Task.task_wakeup()]>> for connection <WebRequest at 0x7f8da0c16250 method=POST uri=/graphql/ clientproto=HTTP/1.1> took too long to shut down and was killed.

my asgi

    "^subscription", channels_jwt_middleware(MyConsumer.as_asgi(schema=schema))
)

application = ProtocolTypeRouter({
    "http": django_asgi_app,
    "websocket":
        QueryAuthMiddleware(
            URLRouter([
                subscription_url,
            ])

    ),
})```

my custom MyConsumer

```class MyConsumer(GraphQLWSConsumer):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.profile_id = None

    async def __call__(self, scope, receive, send):
        user = scope.get("user", None)
        time_zone = await get_current_timezone(user)
        self.profile_id = scope.get("active_profile_id", None)
        self.timezone = time_zone if time_zone else settings.TIME_ZONE
        await super().__call__(scope, receive, send)

    async def connect(self):
        await super().connect()
        await change_status(True, self.profile_id)

    async def disconnect(self, close_code, *args, **kwargs):
        await super().disconnect(close_code)
        await change_status(False, self.profile_id)```
1

There are 1 answers

0
Kirill On

Solve for my issue

daphne -b 0.0.0.0 -p $SERVER_PORT --application-close-timeout 60 --proxy-headers server.asgi:application