From b6a881a65751ae1efe7da6764a80e366fe5627fa Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Tue, 29 Jan 2019 12:02:53 -0500 Subject: [PATCH 1/2] Drop the processed task from all_tasks() list early --- aiohttp/web_protocol.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aiohttp/web_protocol.py b/aiohttp/web_protocol.py index d44ddcdf048..61fa5d1da23 100644 --- a/aiohttp/web_protocol.py +++ b/aiohttp/web_protocol.py @@ -428,6 +428,8 @@ async def start(self) -> None: resp = self.handle_error(request, 504) except Exception as exc: resp = self.handle_error(request, 500, exc) + # Drop the processed task from asyncio.Task.all_tasks() early + del task try: prepare_meth = resp.prepare From 63deba36914edbb538e5255f9d2639c8cbea04c5 Mon Sep 17 00:00:00 2001 From: Andrew Svetlov Date: Tue, 29 Jan 2019 12:04:54 -0500 Subject: [PATCH 2/2] Add changelog --- CHANGES/3587.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 CHANGES/3587.bugfix diff --git a/CHANGES/3587.bugfix b/CHANGES/3587.bugfix new file mode 100644 index 00000000000..c0f6729cfa2 --- /dev/null +++ b/CHANGES/3587.bugfix @@ -0,0 +1 @@ +Drop the processed task from ``all_tasks()`` list early. It prevents logging about a task with unhandled exception when the server is used in conjunction with ``asyncio.run()``.