Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pipinet opened this issue Jul 22, 2024 · 2 comments
Open

Comments

@pipinet
Copy link
Contributor

pipinet commented Jul 22, 2024

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
@fred-labs
Copy link
Contributor

Please submit a PR.

@pipinet
Copy link
Contributor Author

pipinet commented Oct 16, 2024

@fred-labs #212

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants