From 23948e334af8a90f4cfd1270dac435c337e42937 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 17 Nov 2023 21:28:34 +0000 Subject: [PATCH] Await cancelled task (#622) --- aiohttp_devtools/runserver/watch.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aiohttp_devtools/runserver/watch.py b/aiohttp_devtools/runserver/watch.py index be4e3a4a..bf217967 100644 --- a/aiohttp_devtools/runserver/watch.py +++ b/aiohttp_devtools/runserver/watch.py @@ -2,10 +2,10 @@ 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 -from contextlib import suppress from aiohttp import ClientSession, web from aiohttp.client_exceptions import ClientError, ClientConnectionError @@ -36,9 +36,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)