Uvicorn in Windows kills subprocesses on reload #2292
Replies: 5 comments 6 replies
-
I believe, the reason for this could be that on reload, uvicorn does a os.kill(pid, signal.CTRL_C_EVENT) and if the pid is that of an individual process instead of a process group it leads to the CTRL+C signal being sent to everything under the terminal. It's a bug that's been reported in the following links: |
Beta Was this translation helpful? Give feedback.
-
Does this happen with uvicorn 0.28.0? |
Beta Was this translation helpful? Give feedback.
-
@sid-38 @Kludex have there been any updates relating to this? We are running our various dev servers under a unified internal CLI, and this issue prevents us from being able to use Uvicorn's |
Beta Was this translation helpful? Give feedback.
-
@ixxie I have been suffering this issue as well and apparently is not uvicorn's fault, it's more related to the way Python implements os.kill together with the Windows API itself, there's a discussion in this thread https://discuss.python.org/t/terminateprocess-via-os-kill-on-windows/30882/5 i have tried the |
Beta Was this translation helpful? Give feedback.
-
@Kludex I understand if this is too much of an edge case to address directly in the codebase; but I think it would be fair to document this limitation and maybe even link to the relevant discussions. Ideally, maybe some workaround could be suggested also, using third-party tools. Would you be open to me creating an issue along these lines? Eventually, I'm happy to open a pull request to the docs, but I thought an issue would be appropriate first. |
Beta Was this translation helpful? Give feedback.
-
Uvicorn server with reload=True, would send a Ctrl+C event to other subprocesses when reloading.
On making changes to the uvicorn_main.py file, uvicorn reloads and the frontend loop ends.
Uvicorn version - 0.29.0
Watchfiles version - 0.21.0
Python version - 3.12.2
OS - Windows 11 Home
Beta Was this translation helpful? Give feedback.
All reactions