Skip to content

Commit d25ae82

Browse files
authored
Merge pull request #2 from njhale/fix/handle-interrupt
fix: gracefully exit on interrupt
2 parents 2107114 + fbf127d commit d25ae82

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
@@ -111,6 +111,10 @@ async def convert_stream(stream: Stream[ChatCompletionChunk]) -> AsyncIterable[s
111111

112112
if __name__ == "__main__":
113113
import uvicorn
114+
import asyncio
114115

115-
uvicorn.run("main:app", host="127.0.0.1", port=int(os.environ.get("PORT", "8000")),
116+
try:
117+
uvicorn.run("main:app", host="127.0.0.1", port=int(os.environ.get("PORT", "8000")),
116118
log_level="debug" if debug else "critical", reload=debug, access_log=debug)
119+
except (KeyboardInterrupt, asyncio.CancelledError):
120+
pass

0 commit comments

Comments
 (0)