From 8a1baeb9d5093a9b38e11bd1443f981b57820a51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=2E=20K=C3=A4rkk=C3=A4inen?= Date: Fri, 28 Feb 2020 19:25:03 +0200 Subject: [PATCH] Terminate check_timeouts once connection_task finishes. --- sanic/server.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sanic/server.py b/sanic/server.py index af146a01..ccf70ea8 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -202,6 +202,8 @@ class HttpProtocol(asyncio.Protocol): def check_timeouts(self): """Runs itself once a second to enforce any expired timeouts.""" + if not self._task: + return duration = current_time() - self._time lifespan = self._http.lifespan if lifespan == Lifespan.IDLE and duration > self.keep_alive_timeout: