Skip to content

Commit 122a6bf

Browse files
Use class-attribute to track shutdown
1 parent 95cc5c4 commit 122a6bf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

uvicorn/server.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ def __init__(self) -> None:
4848
self.default_headers: list[tuple[bytes, bytes]] = []
4949

5050

51+
class ShutdownTrigger:
52+
is_shutdown_triggered: bool = False
53+
54+
5155
class Server:
5256
def __init__(self, config: Config) -> None:
5357
self.config = config
@@ -261,7 +265,7 @@ async def on_tick(self, counter: int) -> bool:
261265
async def shutdown(self, sockets: list[socket.socket] | None = None) -> None:
262266
if self.config.shutdown_delay:
263267
logger.info(f"Shutting down in {self.config.shutdown_delay} seconds")
264-
self.config.app.uvicorn_shutdown_triggered = True
268+
ShutdownTrigger.is_shutdown_triggered = True
265269
await asyncio.sleep(self.config.shutdown_delay)
266270

267271
logger.info("Shutting down")

0 commit comments

Comments
 (0)