Beispiel #1
0
def test_async_all_done_pre_flag():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    cirq.testing.assert_asyncio_still_running(done)
    pool.set_all_work_received_flag()
    cirq.testing.assert_asyncio_will_have_result(done, None)
Beispiel #2
0
async def test_async_all_done_pre_flag():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    assert await cirq.testing.asynchronous.asyncio_pending(done)
    pool.set_all_work_received_flag()
    assert await done is None
Beispiel #3
0
def test_async_all_done_flag_then_finish_work():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    work = asyncio.Future()
    pool.include_work(work)
    pool.set_all_work_received_flag()

    cirq.testing.assert_asyncio_still_running(done)
    work.set_result(5)
    cirq.testing.assert_asyncio_will_have_result(done, None)
Beispiel #4
0
async def test_async_all_done_flag_then_finish_work():
    pool = CompletionOrderedAsyncWorkPool()
    done = pool.async_all_done()

    work = asyncio.Future()
    pool.include_work(work)
    pool.set_all_work_received_flag()

    assert await cirq.testing.asynchronous.asyncio_pending(done)
    work.set_result(5)
    assert await done is None
Beispiel #5
0
def test_async_all_done_post_flag():
    pool = CompletionOrderedAsyncWorkPool()
    pool.set_all_work_received_flag()
    cirq.testing.assert_asyncio_will_have_result(pool.async_all_done(), None)
    cirq.testing.assert_asyncio_will_have_result(pool.async_all_done(), None)