Ejemplo n.º 1
0
async def _coro_cancel_itself_after_sleep(future):
    await _sleep(0.0001)
    aio.current_task().cancel()
    await future
Ejemplo n.º 2
0
async def _coro_cancel_itself(future):
    aio.current_task().cancel()
    await future
Ejemplo n.º 3
0
async def _coro_return_current_task():
    return aio.current_task()
Ejemplo n.º 4
0
def test_current_task_on_explicit_non_running_loop(loop):
    assert aio.current_task(loop) is None
Ejemplo n.º 5
0
def test_current_task_on_not_running_loop():
    with pytest.raises(RuntimeError):
        aio.current_task()
Ejemplo n.º 6
0
def test_current_task_in_call_soon(loop):
    tasks = []
    loop.call_soon(lambda: tasks.append(aio.current_task()))
    loop.call_soon(_Stopper(loop))
    loop.run_forever()
    assert tasks == [None]