restartable doesn't work with uvicorn in the expec...
# general
m
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
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
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
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
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
ah ok, that can be as well
So, why are we sending
SIGKILL
?
can I control this behavior? 🤔
w
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
sorry, I didn't see the suggestion on your words 🤔 You mean sending TERM, waiting x and then KILL?
w
right
m
yep, that would be perfect 👍
ppl may want to configure the timeout, or not have this behavior tho? not sure 🤔
w
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
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
got it.
m
cool! thanks 👍