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

Solver does not implement signal handling #1

Open
daajoe opened this issue Jul 17, 2019 · 0 comments
Open

Solver does not implement signal handling #1

daajoe opened this issue Jul 17, 2019 · 0 comments

Comments

@daajoe
Copy link

daajoe commented Jul 17, 2019

Your solver does not implement signal handling to the started process tree. This results in the situation that the sat solver (clasp) might still be running even though the benchmark tool or cluster scheduler sent a kill signal to the solver after timeout.
(check with kill -15 mysolver or kill -9 mysolver)

import signal
# SETUP SIGNAL HANDLING
signal.signal(signal.SIGTERM, utils.signals.handler)
signal.signal(signal.SIGINT, utils.signals.handler)

#!/usr/bin/env python
# coding=utf-8
import logging
import os
import sys

import psutil

def handler(signum, frame):
    logging.error('signum %s' % signum)
    current_process = psutil.Process()
    children = current_process.children(recursive=True)
    for child in children:
        logging.error('Child pid is {}\n'.format(child.pid))
        logging.error('Killing child.')
        try:
            os.kill(child.pid, 15)
        except OSError as e:
            logging.warn('Process might already be gone. See error below.')
            logging.warn('%s' % str(e))

    logging.warn('SIGNAL received')
    if signum == 15:
        raise TimeoutException('signal')
    else:
        raise InterruptException('signal')


def nothing(signum, frame):
    logging.warn('SIGNAL received\n')
    logging.warn('SIGNAL ignored...\n')

might be helpful

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

1 participant