Exemplo n.º 1
0
    def spawn_worker(self, calibrate_loops, calibrate_warmups):
        env = create_environ(self.args.inherit_environ, self.args.locale)

        rpipe, wpipe = create_pipe()
        with rpipe:
            with wpipe:
                warg = wpipe.to_subprocess()
                cmd = self.worker_cmd(calibrate_loops, calibrate_warmups, warg)

                kw = {}
                if MS_WINDOWS:
                    # Set close_fds to False to call CreateProcess() with
                    # bInheritHandles=True. For pass_handles, see
                    # http://bugs.python.org/issue19764
                    kw['close_fds'] = False
                elif sys.version_info >= (3, 2):
                    kw['pass_fds'] = [wpipe.fd]

                proc = subprocess.Popen(cmd, env=env, **kw)

            with popen_killer(proc):
                with rpipe.open_text() as rfile:
                    bench_json = rfile.read()

                exitcode = proc.wait()

        if exitcode:
            raise RuntimeError("%s failed with exit code %s" %
                               (cmd[0], exitcode))

        return _load_suite_from_pipe(bench_json)
Exemplo n.º 2
0
def run_command(cmd, **kw):
    proc = subprocess.Popen(cmd, **kw)
    with popen_killer(proc):
        proc.wait()
    return proc.returncode