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

Signal handling #61

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Signal handling #61

wants to merge 2 commits into from

Conversation

bartvm
Copy link
Member

@bartvm bartvm commented Feb 17, 2016

The current platoon-launcher script seems a bit messy with handling its processes. I added an option that allows the user to gracefully signals in the controller. So if you add this to the controller:

class CustomController(Controller):
    def __init__(self, ...):
        self._stop = False
        signal.signal(signal.SIGTERM, self.stop)
        signal.signal(signal.SIGINT, self.stop)

    def stop(self, signum, frame):
        self._stop = True
        signal.signal(signal.SIGTERM, signal.SIG_DFL)
        signal.signal(signal.SIGINT, signal.SIG_DFL)

    def handle_control(self, req, worker_id):
        if self._stop:
            return 'stop'

your workers will just get a stop command the next time they make a request. This way things can terminate gracefully on clusters or when the user presses CTRL-C to end an experiment.

@bartvm bartvm mentioned this pull request Feb 18, 2016
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

Successfully merging this pull request may close these issues.

2 participants