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.
This commit is contained in:
Jeong YunWon 2017-12-14 18:40:30 +09:00
parent 72254a7af9
commit d54b406cba

View File

@ -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: