django-health-check icon indicating copy to clipboard operation
django-health-check copied to clipboard

Django 3.2.2 & "Application instance <Task pending [...] took too long to shut down and was killed." issue

Open Sajam opened this issue 3 years ago • 1 comments

Hi guys!

First - thanks for your hard work - we're heavily using your package for our health check and it works great!

To the point: we recently upgraded Django to version 3.2.2 and we started to receive the following errors (example one, there are different variations of it depending on a check):

Application instance <Task pending name='Task-387' coro=<StaticFilesWrapper.__call__() running at /usr/local/lib/python3.9/site-packages/channels/staticfiles.py:44> wait_for=<Future pending cb=[_chain_future.<locals>._call_check_cancel() at /usr/local/lib/python3.9/asyncio/futures.py:384, <TaskWakeupMethWrapper object at 0x7f78e86dafd0>()]>> for connection <WebSocketProtocol client=['172.18.0.11', 52972] path=b'/ws/user/'> took too long to shut down and was killed.

When we tried to open the health check page it just hung and never loaded.

After hours of debugging, we discovered (thanks to Maciek!) that it was enough to re-register default plugins in our AppConfig:

Selection_999(922)

... and it started to work again!

I'm wondering if it has something to do with minor changes to AppConfig in Django 3.2 described here: https://docs.djangoproject.com/en/3.2/releases/3.2/#automatic-appconfig-discovery but I wasn't able to verify/tell what is the root cause.

Posting it for future reference and maybe someone will be able to find and fix the root issue.

Thanks, Daniel

Sajam avatar May 07 '21 08:05 Sajam

Hi @Sajam,

I honestly don't know. I am not so involved with this part of the Django development. Besides, I currently don't use this package myself, so it's a bit harder to reproduce your scenario.

Therefore, if anyone has more details on this, help would be more than welcome.

Best, Joe

codingjoe avatar May 07 '21 08:05 codingjoe