From cbabe7ec4ae6419f39f5f630e93c2fd12e3aebd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=2E=20K=C3=A4rkk=C3=A4inen?= Date: Mon, 2 Mar 2020 17:06:18 +0200 Subject: [PATCH] Avoid error messages on PayloadTooLarge. --- sanic/http.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sanic/http.py b/sanic/http.py index 3009fdc9..d1b8f08b 100644 --- a/sanic/http.py +++ b/sanic/http.py @@ -91,8 +91,11 @@ class Http: if self.request_body: if self.response and 200 <= self.response.status < 300: logger.error(f"{self.request} body not consumed.") - async for _ in self: - pass + try: + async for _ in self: + pass + except PayloadTooLarge: + self.keep_alive = False # Exit and disconnect if no more requests can be taken if self.stage is not Stage.IDLE or not self.keep_alive: break