django / channels

Developer-friendly asynchrony for Django

Home Page:https://channels.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Application instance <Task pending name='Task-1' coro=<StaticFilesWrapper.__call__() running at D:\project\python-api\venv\lib\site-packages\channels\staticfiles.py:44> wait_for=<Future pending cb=[Task.task_wakeup()]>> for connection <WebSocketProtocol client=['127.0.0.1', 52366] path=b'/ws/graph/'> took too long to shut down and was killed.

JshPngnbn opened this issue · comments

I am using Django Channel for a real-time sending and saving data but when I refresh the page the error came up. I don't know why but, on first load the system is okay but if I reload the page the log appears.

Terminal

Application instance <Task pending name='Task-1' coro=<StaticFilesWrapper.call() running at D:\project\python-api\venv\lib\site-packages\channels\staticfiles.py:44> wait_for=> for connection <WebSocketProtocol client=['127.0.0.1', 52366] path=b'/ws/graph/'> took too long to shut down and was killed.

Consumer.py

async def connect(self):
event= eventhubreader.EventReader()
async def cb(partition, events):
data = events[len(events)-1]
mock = event.generateMockData(data.body_as_json())
await self.send(json.dumps(mock))
await self.accept()
while True:
await event.startReadMessage("HostName","name",cb)

evenhubreader.py

def generateMockData(self,event):
data = {}
now = datetime.now()
data["temperature"] = random.randint(23,25)
data["tss"] = random.randint(5,8)
data["vss"] = random.randint(1,4)
data["bod"] = random.randint(1,7)
data["doc"] = random.randint(8,13)
data["cod"] = random.randint(5,12)
data["ph"] = random.randint(2,13)
data["turbidity"] = random.randint(1,5)
data["conductivity"] = random.randint(1,7)
data['datetime'] = now.strftime("%d/%m/%Y %H:%M:%S")
return data

requirements.txt

arrow==1.2.2
asgiref==3.5.2
azure-core==1.24.2
azure-eventhub==5.10.0
azure-iot-device==2.11.0
azure-iot-hub==2.6.0
channels==3.0.5
cryptography==37.0.4
daphne==3.0.2
Django==4.1
django-crispy-forms==1.14.0
pandas==1.4.3
pendulum==2.1.2
pipreqs==0.4.11
plotly==5.9.0
psycopg2==2.9.3
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycparser==2.21
pydantic==1.9.1
PyJWT==2.4.0
pyOpenSSL==22.0.0
pyparsing==3.0.9
PyPika==0.48.9
PySocks==1.7.1
python-dateutil==2.8.2
python-dotenv==0.20.0
python-engineio==4.3.3
python-slugify==6.1.2
python-socketio==5.7.1
websockets==10.3

There's really not enough here to be able to identify the issue.

If you can produce a minimal running example that reproduces the problem then I can have a look but without that it's impossible to say.