From eb195c600415469d1dde1829186c95f2765047cc Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Mon, 15 May 2017 09:38:39 -0700 Subject: [PATCH] Don't break if protocol is removed before it's put into reply_protocols --- daphne/ws_protocol.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/daphne/ws_protocol.py b/daphne/ws_protocol.py index 2b22e94..502f340 100755 --- a/daphne/ws_protocol.py +++ b/daphne/ws_protocol.py @@ -230,7 +230,8 @@ class WebSocketProtocol(WebSocketServerProtocol): Call to clean up this socket after it's closed. """ if hasattr(self, "reply_channel"): - del self.factory.reply_protocols[self.reply_channel] + if self.reply_channel in self.factory.reply_protocols: + del self.factory.reply_protocols[self.reply_channel] def duration(self): """