From 1f788c707b47b96e81ebba19a1f8ac5c4cd73ac2 Mon Sep 17 00:00:00 2001 From: pipinet Date: Wed, 16 Oct 2024 10:54:21 +0800 Subject: [PATCH] chore: add register_signal option to ScenarioExecution for thread --- .../scenario_execution/scenario_execution_base.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scenario_execution/scenario_execution/scenario_execution_base.py b/scenario_execution/scenario_execution/scenario_execution_base.py index 1a1e9a30..9f71c22e 100644 --- a/scenario_execution/scenario_execution/scenario_execution_base.py +++ b/scenario_execution/scenario_execution/scenario_execution_base.py @@ -92,13 +92,15 @@ def __init__(self, setup_timeout=py_trees.common.Duration.INFINITE, tick_period: float = 0.1, scenario_parameter_file=None, - logger=None) -> None: + logger=None, + register_signal=True) -> None: def signal_handler(sig, frame): self.on_scenario_shutdown(False, "Aborted") - signal.signal(signal.SIGHUP, signal_handler) - signal.signal(signal.SIGTERM, signal_handler) + if register_signal: + signal.signal(signal.SIGHUP, signal_handler) + signal.signal(signal.SIGTERM, signal_handler) self.current_scenario_start = None self.current_scenario = None