Skip to content

SIGUSR1 #2629

Closed Answered by franklinvp
franklinvp asked this question in Q&A
Discussion options

You must be logged in to vote

OK. I think I figured it out.

  1. Add a method handle_usr1 to uvicorn.supervisors.multiprocess.Multiprocess . This is written to set a method thus called as the handler of the SIGUSR1 signal. Make the method run signal.siginterrupt(signal.SIGUSR1, False) and then send SIGUSR1 to each of its self.processes.
  2. Monkey patch uvicorn.server.Server.startup to include a line
    loop.add_signal_handler(
        signal.SIGUSR1,
        getattr(self.config.loaded_app.app.state, 'method_to_do_the_task')
    )
  3. Make sure to add this method to self.config.loaded_app.app.state or somewhere known to the app.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by franklinvp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant