-
-
Notifications
You must be signed in to change notification settings - Fork 870
Open
Description
Initial Checks
- I confirm this was discussed, and the maintainers suggest I open an issue.
- I'm aware that if I created this issue without a discussion, it may be closed without a response.
Discussion Link
https://github.com/Kludex/uvicorn/discussions/2716
Description
When the application hangs during its lifespan, it becomes completely unresponsive to the Ctrl+C command (SIGINT), preventing a graceful shutdown. This forces users to resort to using the kill -9 command.
Example Code
import asyncio
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
import uvicorn
from fastapi import FastAPI
@asynccontextmanager
async def lifespan(_: FastAPI) -> AsyncIterator[None]:
await asyncio.sleep(5000) # Simulates hanging operation
yield
def create_app() -> FastAPI:
return FastAPI(lifespan=lifespan)
if __name__ == "__main__":
uvicorn.run(create_app(), host="0.0.0.0", port=8000)Python, Uvicorn & OS Version
Running uvicorn 0.38.0 with CPython 3.12.11 on Linux
fastapi: 0.121.0
OS: Arch Linux x86_64
Kernel: 6.17.7-arch1-1
Metadata
Metadata
Assignees
Labels
No labels