From 4d1b87ee42d854589c13f67c35ac25fbe7197bc2 Mon Sep 17 00:00:00 2001 From: Kyle Agronick Date: Tue, 27 Nov 2018 13:25:18 -0500 Subject: [PATCH] This fixes the following exception I was seeing in my logs: Nov 27 13:20:47 python3[28665]: File "/var/lib/wwwrun/.virtualenvs//lib/python3.6/site-packages/channels/consumer.py", line 81, in send Nov 27 13:20:47 python3[28665]: await self.base_send(message) Nov 27 13:20:47 python3[28665]: File "/var/lib/wwwrun/.virtualenvs//lib/python3.6/site-packages/channels/sessions.py", line 232, in send Nov 27 13:20:47 python3[28665]: return await self.real_send(message) Nov 27 13:20:47 python3[28665]: File "/var/lib/wwwrun/.virtualenvs//lib/python3.6/site-packages/daphne/server.py", line 213, in handle_reply Nov 27 13:20:47 python3[28665]: if self.connections[protocol].get("disconnected", None): Nov 27 13:20:47 python3[28665]: KeyError: --- daphne/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daphne/server.py b/daphne/server.py index 71ce8f0..17b5e16 100755 --- a/daphne/server.py +++ b/daphne/server.py @@ -210,7 +210,7 @@ class Server(object): Coroutine that jumps the reply message from asyncio to Twisted """ # Don't do anything if the connection is closed - if self.connections[protocol].get("disconnected", None): + if protocol not in self.connections or self.connections[protocol].get("disconnected"): return self.check_headers_type(message) # Let the protocol handle it