Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alamorre opened this issue Aug 31, 2021 · 2 comments

Comments

@alamorre
Copy link

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

@duyanh14
Copy link

I have same issue :(

@mssalnikov
Copy link

That older post has an answer to this here here. Basically, don't override websocket_disconnect, override disconnect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants