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.
This commit is contained in:
1 parent
21f134056d
commit
a8f3933fd0
1 file changed
+3
-8
@@ -714,16 +714,11 @@ def main() -> None:
|
||||
daemon=True,
|
||||
).start()
|
||||
|
||||
for _sig in (signal.SIGTERM, signal.SIGINT): # SIGINT: Ctrl-C / ctl.sh daemons (#7078)
|
||||
try:
|
||||
signal.signal(signal.SIGTERM, _request_shutdown)
|
||||
signal.signal(_sig, _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)
|
||||
logger.debug("Could not install %s handler", _sig, exc_info=True)
|
||||
|
||||
try:
|
||||
httpd.serve_forever()
|
||||
|
||||
Reference in new issue
Block a user