Skip to content

should remove signal in ScenarioExecution __init__ when start in a thread #116

Closed
@pipinet

Description

@pipinet

signal should implement by outside when it need.

in my case i start ScenarioExecution in thread, and i run it without ROS2.

The following code should be executed where it is needed externally, not here

class ScenarioExecution(object):
    """
    Base class for scenario execution.
    Override method run() and method setup_behaviour_tree() to adapt to other middlewares.
    This class can also be executed standalone
    """

    def __init__(self,
                 debug: bool,
                 log_model: bool,
                 live_tree: bool,
                 scenario_file: str,
                 output_dir: str,
                 dry_run=False,
                 render_dot=False,
                 setup_timeout=py_trees.common.Duration.INFINITE,
                 tick_period: float = 0.1,
                 logger=None) -> None:

        def signal_handler(sig, frame):                                     <----------here
            self.on_scenario_shutdown(False, "Aborted").       <----------here

        signal.signal(signal.SIGHUP, signal_handler)               <----------here
        signal.signal(signal.SIGTERM, signal_handler)            <----------here

        self.current_scenario_start = None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions