Skip to content

Application instance took too long to shut down and was killed. For websocket_disconnect() in AsyncConsumer #272

Open
@alamorre

Description

@alamorre

It seems that upon any websocket_disconnect call in a Consumer Class which inherits from AsyncConsumer we get the following error.

Application instance <Task pending coro=<SessionMiddlewareInstance.__call__() running at /Users/adamlamorre/Work/Adam/ChatEngine/api.chatengine.io/venv/lib/python3.6/site-packages/channels/sessions.py:183> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7fcf742f7d08>()]>> for connection <WebSocketProtocol client=['127.0.0.1', 63557] path=b'/person_v3/'> took too long to shut down and was killed.

Here is an example consumer to recreate:

from channels.consumer import AsyncConsumer

class ExampleConsumer(AsyncConsumer):

    async def websocket_connect(self, event):
        await self.send({"type": "websocket.accept"})

    async def websocket_receive(self, event):
        if str(event['text']) == '"ping"':
            await self.send({
                "type": "websocket.send",
                "text": "pong"
            })

    async def websocket_disconnect(self, event):
       # Do anything
       pass

Here are my relevant dependencies and their versions:

asgiref==3.2.10
channels==2.4.0
channels-redis==3.1.0
daphne==2.5.0
Django==3.1.2
djangorestframework==3.11.2

They are older versions to avoid this issue per MrVhek's comment

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