From 36032cc26e082beaa569b2be5bc5d88f9249f60e Mon Sep 17 00:00:00 2001 From: Yun Xu Date: Thu, 11 Oct 2018 22:38:26 -0700 Subject: [PATCH] cancel task when connection_lost --- sanic/server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sanic/server.py b/sanic/server.py index 5668c5c4..8a963203 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -120,6 +120,10 @@ class HttpProtocol(asyncio.Protocol): def connection_lost(self, exc): self.connections.discard(self) + if self._request_handler_task: + self._request_handler_task.cancel() + if self._request_stream_task: + self._request_stream_task.cancel() if self._request_timeout_handler: self._request_timeout_handler.cancel() if self._response_timeout_handler: