

def _run_example(example, log_file):
    example_path = join(example_dir, example)
    code = ("filename = '%s'\n\nimport random\nrandom.seed(1)\n\nimport numpy as np\nnp.random.seed(1)\n\nwith open(filename, 'rb') as example:\n    exec(compile(example.read(), filename, 'exec'))\n" % example_path)
    cmd = ['python', '-c', code]
    cwd = dirname(example_path)
    env = os.environ.copy()
    env['BOKEH_RESOURCES'] = 'relative'
    env['BOKEH_BROWSER'] = 'none'

    class Timeout(Exception):
        pass

    def alarm_handler(sig, frame):
        raise Timeout
    signal.signal(signal.SIGALRM, alarm_handler)
    signal.alarm(10)
    try:
        proc = subprocess.Popen(cmd, cwd=cwd, env=env, stdout=log_file, stderr=log_file)
        return example_path.wait()
    except Timeout:
        warn('Timeout - Example timed out when attempting to run')
        proc.kill()
        return 0
    finally:
        signal.alarm(0)

dataset/ETHPy150Open bokeh/bokeh/tests/examples/test_examples.py _run_example/VarMisuse@145/269 `proc`->`example_path`