Skip to content

Benchmark script: use process groups to manage children #4284

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

Conversation

smowton
Copy link
Contributor

@smowton smowton commented Feb 27, 2019

Previously when a process timed out only the managing shell would be killed;
the underlying process would continue, starving later jobs of CPU time

Previously when a process timed out only the managing shell would be killed;
the underlying process would continue, starving later jobs of CPU time
@smowton smowton force-pushed the smowton/admin/benchmark-script-process-groups branch from da9c1f0 to 0a62867 Compare February 27, 2019 12:19
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 0a62867).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/102491205

@tautschnig
Copy link
Collaborator

Could we instead step-by-step Python-ize this code? Just completely doing the timed execution in Python:

import subprocess
import threading
import time

def run_cmd_with_timeout(cmd, timeout_sec):
    """
    Execute `cmd` in a subprocess and enforce timeout `timeout_sec` seconds.
    Return subprocess exit code on natural completion of the subprocess.
    Raise an exception if timeout expires before subprocess completes.
    """
    t1 = time.time()
    proc = subprocess.Popen(cmd)
    timer = threading.Timer(timeout_sec, proc.kill)
    try:
        timer.start()
        proc.communicate()
    finally:
        timer.cancel()
    t2 = time.time()
    return (proc.returncode, t2 - t1)

@smowton
Copy link
Contributor Author

smowton commented Feb 27, 2019

Fine with me -- if you want to make a PR to replace this whole script I'd vote for that one over this one!

@smowton
Copy link
Contributor Author

smowton commented Feb 28, 2019

If I can get a code owner review I'll merge this for now pending a rewrite

@smowton smowton merged commit caba5a2 into diffblue:develop Feb 28, 2019
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.

4 participants