WARNING - server - Application instance took too long to shut down and was killed
Author: sohamnavadiyaCreated Aug 9, 2018Updated Jul 7, 2025
Labelsblocked/needs-investigation
first message is succeed but further messages throw this exception:
2018-08-09 15:25:32,937 - WARNING - server - Application instance <Task pending coro=<__call__() running at /home/soham/PycharmProjects/lead-generation/venv/lib/python3.5/site-packages/channels/sessions.py:175> wait_for=<Future pending cb=[Task._wakeup()]>> for connection <WebSocketProtocol client=['127.0.0.1', 35996] path=b'/lead/'> took too long to shut down and was killed.My consumer class
class LeadConsumer(AsyncWebsocketConsumer):
async def websocket_connect(self, event):
print("Connected", event)
self.room_group_name = 'lead_list'
# join room group
await self.channel_layer.group_add(
self.room_group_name,
self.channel_name
)
await self.accept()
async def websocket_receive(self, event):
print("Receive", event)
await self.send({
"type": "websocket.send",
"text": "From receive..."
})
async def websocket_disconnect(self, event):
print("Disconnect", event)
await self.send({
"type": "websocket.close"
})
async def lead_list(self, event):
_contact = event['contact']
_campaign = event['campaign']
_company = event['company']
_contact_person = event['contact_person']
await self.send(text_data=json.dumps({
'contact': _contact,
'campaign': _campaign,
'contact_person': _contact_person,
'company': _company
}))
requirements.txt
aioredis==1.1.0
asgiref==2.3.2
async-timeout==2.0.1
attrs==18.1.0
autobahn==18.7.1
Automat==0.7.0
certifi==2018.4.16
channels==2.1.2
channels-redis==2.2.1
chardet==3.0.4
constantly==15.1.0
daphne==2.2.1
diff-match-patch==20121119
Django==2.0.7
django-import-export==1.0.1
django-rest-framework==0.1.0
djangorestframework==3.8.2
docutils==0.14
et-xmlfile==1.0.1
hiredis==0.2.0
hyperlink==18.0.0
idna==2.7
incremental==17.5.0
jdcal==1.4
msgpack==0.5.6
odfpy==1.3.6
openpyxl==2.5.4
PyHamcrest==1.9.0
python-decouple==3.1
pytz==2018.5
PyYAML==3.13
requests==2.19.1
six==1.11.0
tablib==0.12.1
Twisted==18.7.0
txaio==18.7.1
unicodecsv==0.14.1
urllib3==1.23
xlrd==1.1.0
xlwt==1.3.0
zope.interface==4.5.0
How to solve my issue?
Thanks in advance.
Source: django/channels