Ejemplo n.º 1
0
def test_wait_for_one_with_error_and_completed():
    def raise_error():
        raise DummyTestError()

    task1 = Task(raise_error).start()
    time.sleep(0.1)
    with pytest.raises(DummyTestError):
        Task.wait_for_one([task1], timeout=1)
Ejemplo n.º 2
0
def test_wait_for_one():
    def coro(t):
        time.sleep(t)
        return "test"

    task1 = Task(coro).start(0.1)
    task2 = Task(coro).start(0.2)

    Task.wait_for_one([task1, task2], timeout=1)
    assert not task1.is_running and task2.is_running, "Failed to wait for task"