From a0ae964ed98162a4aa1f27d45291930f0b5a70b2 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 17 Nov 2023 21:20:25 +0000 Subject: [PATCH 1/2] Await cancelled task --- aiohttp_devtools/runserver/watch.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aiohttp_devtools/runserver/watch.py b/aiohttp_devtools/runserver/watch.py index be4e3a4a..941079e2 100644 --- a/aiohttp_devtools/runserver/watch.py +++ b/aiohttp_devtools/runserver/watch.py @@ -2,6 +2,7 @@ import os import signal import sys +from contextlib import suppress from multiprocessing import Process from pathlib import Path from typing import AsyncIterator, Iterable, Optional, Tuple, Union @@ -36,9 +37,9 @@ async def _run(self) -> None: async def close(self, *args: object) -> None: if self._task: self.stopper.set() - if self._task.done(): - self._task.result() self._task.cancel() + with suppress(asyncio.CancelledError): + await self._task async def cleanup_ctx(self, app: web.Application) -> AsyncIterator[None]: await self.start(app) From acf857d2bae93d04b774e566cf0de2c67d70ec1c Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 17 Nov 2023 21:26:55 +0000 Subject: [PATCH 2/2] Update watch.py --- aiohttp_devtools/runserver/watch.py | 1 - 1 file changed, 1 deletion(-) diff --git a/aiohttp_devtools/runserver/watch.py b/aiohttp_devtools/runserver/watch.py index 941079e2..bf217967 100644 --- a/aiohttp_devtools/runserver/watch.py +++ b/aiohttp_devtools/runserver/watch.py @@ -6,7 +6,6 @@ from multiprocessing import Process from pathlib import Path from typing import AsyncIterator, Iterable, Optional, Tuple, Union -from contextlib import suppress from aiohttp import ClientSession, web from aiohttp.client_exceptions import ClientError, ClientConnectionError