예제 #1
0
def test_recursive_terminate(use_psutil):
    event = ctx_loky.Event()
    p = ctx_loky.Process(target=_run_nested_delayed, args=(4, 1000, event))
    p.start()

    # Wait for all the processes to be launched
    if not event.wait(30):
        recursive_terminate(p, use_psutil=use_psutil)
        raise RuntimeError("test_recursive_terminate was not able to launch "
                           "all nested processes.")

    children = psutil.Process(pid=p.pid).children(recursive=True)
    recursive_terminate(p, use_psutil=use_psutil)

    # The process can take some time finishing so we should wait up to 5s
    gone, alive = psutil.wait_procs(children, timeout=5)
    msg = "Should be no descendant left but found:\n{}"
    assert len(alive) == 0, msg.format(alive)
예제 #2
0
 def teardown_class(cls):
     """Clean up the test environment from any remaining subprocesses.
     """
     for child_process in cls.active_children():
         recursive_terminate(child_process)