skillfed

nest-asyncio2

Patch asyncio to allow nested event loops

nest-asyncio2 Permissive license BSD AGING 20 v1.7.2 released

Install

nest-asyncio2 on PyPI

pip

pip install nest-asyncio2

uv

uv add nest-asyncio2

poetry

poetry add nest-asyncio2

Package 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

Development Status :: 5 - Production/StableFramework :: AsyncIOIntended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

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.
nested asyncio event loopsasyncio.run in jupyterallow nested event loopasyncio runtime error fixrun async code in running loop

Similar packages