From 503634f1bfe79db3f6fd2d415e19d21530b0acc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=87=BA=E9=97=A8=E4=B8=89=E4=B8=8D=E6=83=B9?= Date: Thu, 14 Nov 2024 14:54:12 +0800 Subject: [PATCH] chore: add register_signal option to ScenarioExecution for thread (#212) Co-authored-by: pipinet --- .../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