Skip to content

Commit

Permalink
Add SIGQUIT handler to UvicornWorker (#1710)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcelo Trylesinski <marcelotryle@gmail.com>
  • Loading branch information
adnaanbheda and Kludex committed Nov 1, 2022
1 parent e2d63d0 commit 4fd5077
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions uvicorn/workers.py
Expand Up @@ -76,9 +76,20 @@ def init_signals(self) -> None:
# Don't let SIGUSR1 disturb active requests by interrupting system calls
signal.siginterrupt(signal.SIGUSR1, False)

def _install_sigquit_handler(self) -> None:
"""Install a SIGQUIT handler on workers.
- https://github.com/encode/uvicorn/issues/1116
- https://github.com/benoitc/gunicorn/issues/2604
"""

loop = asyncio.get_running_loop()
loop.add_signal_handler(signal.SIGQUIT, self.handle_exit, signal.SIGQUIT, None)

async def _serve(self) -> None:
self.config.app = self.wsgi
server = Server(config=self.config)
self._install_sigquit_handler()
await server.serve(sockets=self.sockets)
if not server.started:
sys.exit(Arbiter.WORKER_BOOT_ERROR)
Expand Down

0 comments on commit 4fd5077

Please sign in to comment.