From c3cc5d324a8c339398153e62b0ba71e743939af3 Mon Sep 17 00:00:00 2001 From: Dragorn421 Date: Tue, 18 Feb 2025 17:30:00 +0100 Subject: [PATCH] make interrupting less jank by making child processes ignore sigint --- tools/assets/extract/extract_xml_z64.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/assets/extract/extract_xml_z64.py b/tools/assets/extract/extract_xml_z64.py index 3587d331db..69c244950b 100644 --- a/tools/assets/extract/extract_xml_z64.py +++ b/tools/assets/extract/extract_xml_z64.py @@ -302,6 +302,14 @@ def process_pool_wrapped(extraction_ctx, pd): ) from e +# Make interrupting jobs with ^C less jank +# https://stackoverflow.com/questions/72967793/keyboardinterrupt-with-python-multiprocessing-pool +def set_sigint_ignored(): + import signal + + signal.signal(signal.SIGINT, signal.SIG_IGN) + + def main(): import argparse import json @@ -444,7 +452,9 @@ def main(): pools_desc_to_extract = pools_desc_modified if pools_desc_to_extract: - with multiprocessing.Pool(processes=args.jobs) as pool: + with multiprocessing.Pool( + processes=args.jobs, initializer=set_sigint_ignored + ) as pool: jobs = [ ( pd,