From d54b406cbadcb7de126a606e7dee312cbcd0e5df Mon Sep 17 00:00:00 2001 From: Jeong YunWon Date: Thu, 14 Dec 2017 18:40:30 +0900 Subject: [PATCH] Cancel request tasks when response timeout is triggered Before: Even after raising ResponseTimeout, server still processes remaining tasks until it is done After: Before raising ResponseTimeout, server stops working task. --- sanic/server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sanic/server.py b/sanic/server.py index 0d7809d3..d608f8d7 100644 --- a/sanic/server.py +++ b/sanic/server.py @@ -174,6 +174,10 @@ class HttpProtocol(asyncio.Protocol): self.response_timeout_callback) ) else: + if self._request_stream_task: + self._request_stream_task.cancel() + if self._request_handler_task: + self._request_handler_task.cancel() try: raise ServiceUnavailable('Response Timeout') except ServiceUnavailable as exception: