nest-asyncio2
Patch asyncio to allow nested event loops
Install
nest-asyncio2 on PyPI
pip
pip install nest-asyncio2uv
uv add nest-asyncio2poetry
poetry add nest-asyncio2Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 181 days since the last release |
| Last repo commit | |
| First released | |
| Popularity | one of the top 1,000 most-downloaded packages on PyPI (30-day window, as of 2026-08-13) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-13) |
Evidence: nest_asyncio2-1.7.2-py3-none-any.whl
Keywords: asyncio, nested, eventloop
About nest-asyncio2
from the package's own PyPI description — quoted content, verbatim
nest-asyncio2
Build (image) status (image) PyPi (image) License (image) Downloads (image)
Introduction
By design asyncio does not allow
its event loop to be nested. This presents a practical problem:
When in an environment where the event loop is
already running it's impossible to run tasks and wait
for the result. Trying to do so will give the error
"RuntimeError: This event loop is already running".
The issue pops up in various environments, such as web servers, GUI applications and in Jupyter notebooks.
This module patches asyncio to allow nested use of asyncio.run and
loop.run_until_complete.
Installation
pip3 install nest-asyncio2
Python...
Read as markdown · JSON record · Source repository · Homepage
AI interpretation — verify before relying
AI-generated interpretation of the package facts above; every digit, version, license, or vulnerability id it cites is grounded in the facts already shown on this page
Patches asyncio to allow nested event loops, enabling asyncio.run() and loop.run_until_complete() to work within already-running event loops—solving the "event loop is already running" error in Jupyter, web servers, and GUI applications.
Low friction: pure Python wheel with zero runtime dependencies. Maintenance is aging (181 days since last release) but the repository remains active and the package targets current Python versions through 3.14.
BSD permissive license imposes minimal restrictions; you may use, modify, and distribute freely with only attribution and liability disclaimer required.
Usage
pip install nest-asyncio2
import nest_asyncio2
import asyncio
nest_asyncio2.apply()
async def my_async_func():
return "result"
# Now this works even inside an already-running event loop
result = asyncio.run(my_async_func())
Python 3.5 or higher required; only patches asyncio event loops (not uvloop or quamash); may leak one event loop on exit (ResourceWarning on Python 3.12+, hidden by default).
Verdict: Stable, low-friction solution to a real asyncio limitation with broad Python version support and no external dependencies. Maintenance is aging but the package is actively maintained and addresses known issues in newer Python versions. Safe for production use in environments where nested event loops are necessary.
Needs verification
- Whether the leaked event loop behavior (documented as a known issue) impacts real-world applications beyond the hidden ResourceWarning.
- Compatibility with alternative event loop implementations beyond the stated limitation on uvloop and quamash.
Similar packages
permissive · top 1,000 on PyPI
pytest-covpermissive · top 1,000 on PyPI
synchronicitypermissive · top 1,000 on PyPI
exceptiongrouppermissive · top 1,000 on PyPI
uvlooppermissive · top 1,000 on PyPI
deprecationpermissive · top 1,000 on PyPI
jsonpatchpermissive · top 1,000 on PyPI
async-lrupermissive · top 1,000 on PyPI
groqpermissive · top 1,000 on PyPI
aiobotocorepermissive · top 100 on PyPI