From a0ae964ed98162a4aa1f27d45291930f0b5a70b2 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Fri, 17 Nov 2023 21:20:25 +0000 Subject: [PATCH] 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)