nest-asyncio
Patch asyncio to allow nested event loops
Install
nest-asyncio on PyPI
pip
pip install nest-asynciouv
uv add nest-asynciopoetry
poetry add nest-asyncioPackage facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.5) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | abandoned — 935 days since the last release |
| Last repo commit | (repository archived) |
| 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_asyncio-1.6.0-py3-none-any.whl
Keywords: asyncio, nested, eventloop
About nest-asyncio
from the package's own PyPI description — quoted content, verbatim
|Build| |Status| |PyPiVersion| |License| |Downloads|
Introduction
By design asyncio does not allow <https://github.com/python/cpython/issues/66435>_
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
.. code-block::
pip3 install nest_asyncio
Python 3.5 or higher is required.
Usage
.. code-block:: python
import nest_asyncio
nest_asyncio.apply()
Optionally the specific loop that needs patching can be given
as argument to apply, otherwise the current event loop is used.
An event loop can be patched whether it is already running
or not. Only event loops from asyncio can be patched;
Loops from other projects, such as uvloop or quamash,
generally can't be patched.
.. |Build| image::...
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 in environments where an event loop is already running, such as Jupyter notebooks and web servers.
Installation is trivial with no runtime dependencies. However, the package is archived and abandoned as of 2024-01-31, with no maintenance activity for 935 days; it remains marked stable but carries the risk of unfixed issues in future Python versions.
BSD license is permissive and poses no restrictions on use, modification, or distribution in proprietary or open-source projects.
Usage
pip install nest_asyncio==1.6.0
import nest_asyncio
nest_asyncio.apply()
Python 3.5 or higher required; only patches asyncio event loops, not third-party loops like uvloop or quamash.
Verdict: nest_asyncio solves a real problem for running asyncio code in nested contexts with zero dependencies and a permissive license. However, the repository is archived and abandoned since early 2024, leaving no path for maintenance if future Python versions break compatibility or introduce new asyncio internals. Use only if your Python version and asyncio implementation are stable and unlikely to change.
Needs verification
- Whether the patch remains compatible with Python 3.13+ and any planned asyncio changes in future releases.
- Whether there are known incompatibilities or edge cases with specific web frameworks or Jupyter versions.
Similar packages
permissive · top 1,000 on PyPI
exceptiongrouppermissive · top 1,000 on PyPI
synchronicitypermissive · top 1,000 on PyPI
tqdmcopyleft · top 100 on PyPI
jsonpatchpermissive · top 1,000 on PyPI
llama-parsepermissive · top 1,000 on PyPI
gqlpermissive · top 1,000 on PyPI
shapelypermissive · top 1,000 on PyPI
openai-agentspermissive · top 1,000 on PyPI
nbclientpermissive · top 1,000 on PyPI