Esempio n. 1
0
def test_timeout_execute():
    timeout = 3  # TODO: the timeout should be smaller but as a workaround for Pypy slowness/overhead we set it to 3 sec
    func = execute.python(timeout=timeout)(sleep_and_return)

    # Normal case
    result = func(0.25)
    assert result == 0.25

    # Timeout case
    t = time.time()
    with pytest.raises(ExecutionTimeoutError) as e:
        func(10)
    assert (time.time() - t) < 10.0
    assert 'ExecutionTimeoutError after {} seconds'.format(timeout) in str(e.value)
Esempio n. 2
0
def test_timeout_execute():
    timeout = 3  # TODO: the timeout should be smaller but as a workaround for Pypy slowness/overhead we set it to 3 sec
    func = execute.python(timeout=timeout)(sleep_and_return)

    # Normal case
    result = func(0.25)
    assert result == 0.25

    # Timeout case
    t = time.time()
    with pytest.raises(ExecutionTimeoutError) as e:
        func(10)
    assert (time.time() - t) < 10.0
    assert 'ExecutionTimeoutError after {} seconds'.format(timeout) in str(e.value)
Esempio n. 3
0
def test_execute_kill_children():
    pid = execute.python(kill_children=True)(create_sleeper_subprocess)()
    with pytest.raises(psutil.NoSuchProcess):
        psutil.Process(pid)
Esempio n. 4
0
def test_execute_dont_kill_children():
    pid = execute.python()(create_sleeper_subprocess)()
    subprocess = psutil.Process(pid)
    assert subprocess.status() == 'sleeping'
    subprocess.terminate()  # cleanup
Esempio n. 5
0
def test_execute_kill_children():
    pid = execute.python(kill_children=True)(create_sleeper_subprocess)()
    with pytest.raises(psutil.NoSuchProcess):
        psutil.Process(pid)
Esempio n. 6
0
def test_execute_dont_kill_children():
    pid = execute.python()(create_sleeper_subprocess)()
    subprocess = psutil.Process(pid)
    assert subprocess.status() == 'sleeping'
    subprocess.terminate()  # cleanup