From 836e9ca6be56adffffce9be0ac4cceaed08e6918 Mon Sep 17 00:00:00 2001 From: Arthur Lu Date: Fri, 16 Jul 2021 06:12:26 +0000 Subject: [PATCH] added Pool.join to allow threads to exit safely added keyboard interrupt signal ignore in threads --- src/cli/processing.py | 4 ++++ src/cli/superscript.py | 1 + 2 files changed, 5 insertions(+) diff --git a/src/cli/processing.py b/src/cli/processing.py index 1f7e322..3778926 100644 --- a/src/cli/processing.py +++ b/src/cli/processing.py @@ -4,8 +4,12 @@ from tra_analysis import Analysis as an from dataset import push_metric from data import pull_new_tba_matches +import signal + def simplestats(data_test): + signal.signal(signal.SIGINT, signal.SIG_IGN) + data = np.array(data_test[0]) data = data[np.isfinite(data)] ranges = list(range(len(data))) diff --git a/src/cli/superscript.py b/src/cli/superscript.py index 1ad9058..2fe295a 100644 --- a/src/cli/superscript.py +++ b/src/cli/superscript.py @@ -357,6 +357,7 @@ def main(): log(stdout, INF, "detected KeyboardInterrupt, killing threads") if "exec_threads" in locals(): exec_threads.terminate() + exec_threads.join() exec_threads.close() log(stdout, INF, "terminated threads, exiting") loop_stored_exception = sys.exc_info()