示例#1
0
def test_run_with_multiprocess_timeout_preserves_logging(capfd):
    """
    Requires fd capturing because the subprocess output won't be captured by caplog
    """
    run_with_multiprocess_timeout(prefect.Flow("logs").run, timeout=10)
    stdout = capfd.readouterr().out
    assert "Beginning Flow run" in stdout
    assert "Flow run SUCCESS" in stdout
示例#2
0
def test_run_with_multiprocess_timeout_handles_none_return_values():
    def fn():
        return None

    result = run_with_multiprocess_timeout(fn, timeout=10)

    assert result is None
示例#3
0
def test_run_with_multiprocess_timeout_handles_unpicklable_return_values():
    def fn():
        import threading

        # An unpickleable type
        return threading.Lock()

    with pytest.raises(
        RuntimeError,
        match="Failed to pickle result of type 'lock'",
    ) as exc_info:
        run_with_multiprocess_timeout(fn, timeout=12)

    # We include the original exception
    assert "TypeError: cannot pickle '_thread.lock' object" in str(
        exc_info.value
        # Python 3.6/7 have a different error message
    ) or "TypeError: can't pickle _thread.lock objects" in str(exc_info.value)