Exemplo n.º 1
0
def test_thread_timeout(kernel):
    def func():
        with pytest.raises(TaskTimeout):
            with timeout_after(1):
                AWAIT(sleep(2))

    kernel.run(async_thread(func)())
Exemplo n.º 2
0
 async def main():
     lock = Lock()
     async with lock:
         results.append('main')
         t = await spawn(async_thread(func), lock)
         await sleep(0.5)
         results.append('main done')
     await t.join()
Exemplo n.º 3
0
 async def main():
     t = await spawn(async_thread(func))
     await sleep(0.25)
     await t.cancel()
Exemplo n.º 4
0
def test_thread_bad_result(kernel):
    def main():
        with pytest.raises(TypeError):
            result = AWAIT(simple_coro(2, '3'))

    kernel.run(async_thread(main)())
Exemplo n.º 5
0
def test_thread_good_result(kernel):
    def main():
        result = AWAIT(simple_coro(2, 3))
        assert result == 5

    kernel.run(async_thread(main)())
Exemplo n.º 6
0
 async def main():
     t = await spawn(async_thread(func))
     await t.join()