Skip to content

asyncio will be running by default with tornado 5 #11030

Description

@minrk

When tornado 5 is released, which is scheduled to be this month, the tornado ioloop will run on asyncio by default. For the most part, this is nice because asyncio will always be running (#9166), but it's also tricky because simple cells like this that assume asyncio isn't running will stop working:

loop = asyncio.get_event_loop()
# will fail because loop is already running:
loop.run_until_complete(asyncio.sleep(1))

Without something like #10390, there won't be an easy way that I can see for users to run asyncio code in IPython, other than putting them in a background thread where they can run it in an eventloop:

aio_pool = ThreadPoolExecutor(1)

def init_loop():
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    return loop

aio_loop = aio_pool.submit(init_loop).result()

async def mycoro():
    await asyncio.sleep(1)
    return 5

result = aio_pool.submit(lambda : aio_loop.run_until_complete(mycoro())).result()

and #10390 still needs to handle the fact that asyncio will be running, which I don't think it does right now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions