That’s because you’re running uvicorn
as your only server. uvicorn
is not a process manager and, as so, it does not manage its workers life cycle. That’s why they recommend running uvicorn using gunicorn+UvicornWorker for production.
That said, you can kill the spawned workers and trigger it’s shutdown using the script below:
$ kill $(pgrep -P $uvicorn_pid)
The reason why this works but not the kill
on the parent pid is because when you ^C
something, the signal is transmitted throughout all of its spawned processes that are attached to the stdin
.