From 31a8706b422452366ab98804b95f8a7b45ae4a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=2E=20K=C3=A4rkk=C3=A4inen?= Date: Sun, 1 Mar 2020 17:10:04 +0200 Subject: [PATCH] Fix a middleware cancellation handling test with py38. --- sanic/app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sanic/app.py b/sanic/app.py index 0f61cbfe..d0ccc9e9 100644 --- a/sanic/app.py +++ b/sanic/app.py @@ -961,6 +961,10 @@ class Sanic: response = await self._run_response_middleware( request, response, request_name=name ) + except CancelledError: + # FIXME: Ensure exiting in a clean manner instead of this + # and verify py37 and py38 test_middleware.py separately + request.stream.keep_alive = False except Exception: error_logger.exception( "Exception occurred in one of response "