django / channels_redis

Redis channel layer backend for Django Channels
BSD 3-Clause "New" or "Revised" License
602 stars 197 forks source link

Connection.disconnect: Task was destroyed but it is pending! #328

Closed bellini666 closed 2 years ago

bellini666 commented 2 years ago

This is similar to https://github.com/django/channels_redis/issues/327 but happens when using RedisPubSubChannelLayer:

Task was destroyed but it is pending!
task: <Task pending name='Task-133' coro=<Connection.disconnect() running at /home/bellini/dev/2u/backend/.venv/lib/python3.10/site-packages/redis/asyncio/connection.py:837> wait_for=<Future finished result=None>

Like the other issue, it seems that it happens because the connection gets disconnected from the __del__ method, but in this case the loop is already closed and cannot run it.

The fix here is trivial and I'm already opening a PR for it in a few minutes.