Skip to content

Commit 504415b

Browse files
authored
Merge pull request #7 from njhale/fix/handle-interrupts
fix: gracefully exit on interrupt
2 parents 6b5a880 + 830169d commit 504415b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

main.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ async def completions(request: Request) -> StreamingResponse:
4747

4848
if __name__ == "__main__":
4949
import uvicorn
50+
import asyncio
5051

51-
uvicorn.run("main:app", host="127.0.0.1", port=int(os.environ.get("PORT", "8000")),
52+
try:
53+
uvicorn.run("main:app", host="127.0.0.1", port=int(os.environ.get("PORT", "8000")),
5254
log_level="debug" if debug else "critical", reload=debug, access_log=debug)
55+
except (KeyboardInterrupt, asyncio.CancelledError):
56+
pass

0 commit comments

Comments
 (0)