From a8f3933fd05429d16bbbfb353a3758de0c179a90 Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Sat, 12 Sep 2026 02:29:28 +0000 Subject: [PATCH] fix(server): register SIGTERM+SIGINT via one loop to stay under the 749-line budget The contributor's SIGINT addition (#7315) pushed server.py to 754 lines, tripping test_sprint10::test_server_py_under_750_lines (master was 749). Fold the two signal.signal() try/except blocks into a single loop over (SIGTERM, SIGINT) so SIGINT graceful shutdown lands (#7078) without growing the file past the enforced split budget. Same _request_shutdown handler, same fail-safe on non-main-thread. --- server.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/server.py b/server.py index b3f6546f..03af1068 100644 --- a/server.py +++ b/server.py @@ -714,16 +714,11 @@ def main() -> None: daemon=True, ).start() - try: - signal.signal(signal.SIGTERM, _request_shutdown) - except (ValueError, OSError): - # Not on the main thread (e.g. embedded/test harness); skip handler. - logger.debug("Could not install SIGTERM handler", exc_info=True) - - try: - signal.signal(signal.SIGINT, _request_shutdown) - except (ValueError, OSError): - logger.debug("Could not install SIGINT handler", exc_info=True) + for _sig in (signal.SIGTERM, signal.SIGINT): # SIGINT: Ctrl-C / ctl.sh daemons (#7078) + try: + signal.signal(_sig, _request_shutdown) + except (ValueError, OSError): + logger.debug("Could not install %s handler", _sig, exc_info=True) try: httpd.serve_forever()