From 6dcc0d52b3c4ca97df8cc47bd93672076a87bd7e Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Sun, 24 Jun 2018 16:33:54 -0700 Subject: [PATCH] send() should not block once connection is closed --- daphne/server.py | 4 ++++ setup.cfg | 1 + 2 files changed, 5 insertions(+) diff --git a/daphne/server.py b/daphne/server.py index 6a65ebb..d8d43f2 100755 --- a/daphne/server.py +++ b/daphne/server.py @@ -195,6 +195,10 @@ 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): + return + # Let the protocol handle it protocol.handle_reply(message) ### Utility diff --git a/setup.cfg b/setup.cfg index 4223ddf..8c9a5f5 100644 --- a/setup.cfg +++ b/setup.cfg @@ -7,6 +7,7 @@ addopts = tests/ [isort] line_length = 120 multi_line_output = 3 +known_first_party = channels,daphne,asgiref [flake8] exclude = venv/*,tox/*,docs/*,testproject/*,js_client/*,.eggs/*