diff --git a/uvicorn/server.py b/uvicorn/server.py index 8d43896c2..ce168287b 100644 --- a/uvicorn/server.py +++ b/uvicorn/server.py @@ -47,6 +47,8 @@ def __init__(self) -> None: self.tasks: set[asyncio.Task[None]] = set() self.default_headers: list[tuple[bytes, bytes]] = [] +class ShutdownTrigger: + is_shutdown_triggered: bool = False class Server: def __init__(self, config: Config) -> None: @@ -261,7 +263,7 @@ async def on_tick(self, counter: int) -> bool: async def shutdown(self, sockets: list[socket.socket] | None = None) -> None: if self.config.shutdown_delay: logger.info(f"Shutting down in {self.config.shutdown_delay} seconds") - self.config.app.uvicorn_shutdown_triggered = True + ShutdownTrigger.is_shutdown_triggered = True await asyncio.sleep(self.config.shutdown_delay) logger.info("Shutting down")