_asyncio_utils.py 363 Bytes
Newer Older
xuebingbing's avatar
xuebingbing committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
"""test utilities that use async/await syntax

a separate file to avoid syntax errors on Python 2
"""

import asyncio


def async_func():
    """Simple async function to schedule a task on the current eventloop"""
    loop = asyncio.get_event_loop()
    assert loop.is_running()

    async def task():
        await asyncio.sleep(1)

    loop.create_task(task())