import asyncio


def loop(request):
    """Create a asyncio event loop."""
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)

    def teardown():
        loop.close()

    request.addfinalizer(teardown)

    return loop