From 46521240a943e66616b5ed899206564ddab603d6 Mon Sep 17 00:00:00 2001 From: r0fls Date: Wed, 3 Jan 2018 23:33:22 -0800 Subject: [PATCH] fix timeout bug when self.transport is None --- sanic/server.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sanic/server.py b/sanic/server.py index d608f8d7..af6dc62d 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -431,7 +431,10 @@ class HttpProtocol(asyncio.Protocol): if self.parser and (self.keep_alive or getattr(response, 'status', 0) == 408): self.log_response(response) - self.transport.close() + try: + self.transport.close() + except AttributeError as e: + logger.debug('Connection lost before server could close it.') def bail_out(self, message, from_error=False): if from_error or self.transport.is_closing():