https://pantsbuild.org/ logo
m

modern-wolf-36228

10/12/2021, 11:18 AM
restartable doesn't work with uvicorn in the expected way, more on thread
uvicorn
shutdown behavior is the following: • If you send
SIGTERM
or
SIGINT
, it will set a variable
should_exit
to True, and it will start the graceful shutdown. • If you send another
SIGTERM
or
SIGINT
, it will set a variable
force_exit
to True, and it will force the exit.
for what I'm seeing,
uvicorn
is receiving two signals, due to that it cannot shutdown gracefully 🤔
c

curved-television-6568

10/12/2021, 11:34 AM
Perhaps there should be a shutdown grace period timeout, that’ll dictate how long we should expect to wait for a process to die cleanly before killing it? Not sure if that’s relevant here, but perhaps could come in handy in case a process is a bit slow to shutdown.. @witty-crayon-22786
m

modern-wolf-36228

10/12/2021, 11:35 AM
the thing is that this process that I'm running doesn't take time to shutdown, but the double signal doesn't give that opportunity
"doesn't take time" = the timeout shouldn't matter
c

curved-television-6568

10/12/2021, 11:52 AM
Yeah, sorry for hi-jacking the thread, I just realized that this could be an edge case to consider..
1
Double signals seems like a bug
w

witty-crayon-22786

10/12/2021, 3:50 PM
interesting… i’m surprised you get more than one signal… if anything, i would think that you got only
SIGKILL
which two signals are you seeing?
m

modern-wolf-36228

10/12/2021, 4:08 PM
ah ok, that can be as well
So, why are we sending
SIGKILL
?
can I control this behavior? 🤔
w

witty-crayon-22786

10/12/2021, 4:10 PM
mostly because it’s the only signal you don’t really need to wait for a response to… but if it’s valuable to send TERM in this case, i can look at that
i’ll probably see if there is any sort of convention or standard that we should be following here… i know that TERM, wait a bit, then KILL is a convention.
would that work for your needs?
m

modern-wolf-36228

10/12/2021, 4:18 PM
sorry, I didn't see the suggestion on your words 🤔 You mean sending TERM, waiting x and then KILL?
w

witty-crayon-22786

10/12/2021, 4:18 PM
right
m

modern-wolf-36228

10/12/2021, 4:18 PM
yep, that would be perfect 👍
ppl may want to configure the timeout, or not have this behavior tho? not sure 🤔
w

witty-crayon-22786

10/12/2021, 4:19 PM
yea. hopefully that’s not a per-binary setting.
@modern-wolf-36228: to help me understand priority: what is the impact of
uvicorn
being killed like this? does it fail to restart, or just fail to clean up files/processes it created?
m

modern-wolf-36228

10/12/2021, 4:22 PM
it doesn't run what we call a "shutdown event", it's basically a function (defined by the user) that is called when uvicorn is asked to shutdown
it restarts ok the way it is
so it can clean up many things, what specifically, is defined by the user
w

witty-crayon-22786

10/12/2021, 4:24 PM
got it.
m

modern-wolf-36228

10/12/2021, 5:06 PM
cool! thanks 👍
4 Views