From 5550b20cdd347d59e2aa68f6ebf9e9abffaff9fc Mon Sep 17 00:00:00 2001 From: Miguel Grinberg Date: Wed, 8 Nov 2023 00:09:43 +0000 Subject: [PATCH] Handle change in wait_closed() behavior in python 3.12 (Fixes #177) --- src/microdot_asyncio.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/microdot_asyncio.py b/src/microdot_asyncio.py index 654e3bf..45c8c10 100644 --- a/src/microdot_asyncio.py +++ b/src/microdot_asyncio.py @@ -280,6 +280,11 @@ async def aclose(self): while True: try: + if hasattr(self.server, 'serve_forever'): # pragma: no cover + try: + await self.server.serve_forever() + except asyncio.CancelledError: + pass await self.server.wait_closed() break except AttributeError: # pragma: no cover