Skip to content

asyncio.get_event_loop raises error instead of spawning new loop when no loop is running. #702

@anonymousx97

Description

@anonymousx97
>>> import uvloop, asyncio
>>> asyncio.get_event_loop()
<_UnixSelectorEventLoop running=False closed=False debug=False>
>>> uvloop.install()
>>> asyncio.get_event_loop()
Traceback (most recent call last):
  File "<python-input-4>", line 1, in <module>
    asyncio.get_event_loop()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/uvloop/__init__.py", line 206, in get_event_loop
    raise RuntimeError(
    ...<2 lines>...
    )
RuntimeError: There is no current event loop in thread 'MainThread'.
>>>

As you can see in the snippet above when run on un-patched asyncio it's returning a new loop. But uvloop raises error because of the method override which was not there in previous version inheriting the original new loop spawning function.

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