Skip to content

asyncio.run() from inside asyncio.run() causes hard crash #11128

Description

@dhalbert

(Distilled from #10329)

This program causes a hard safe-mode crash:

import asyncio

async def f():
    pass

async def g():
    while True:
        asyncio.run(f())
        await asyncio.sleep(10) # necessary

asyncio.run(g())

g() needs to have a loop and an asyncio.sleep() in it to exercise the bug.

In CPython, running the same code raises an error:

RuntimeError: asyncio.run() cannot be called from a running event loop
<sys>:0: RuntimeWarning: coroutine 'f' was never awaited

This is the same as micropython#15187.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions