skillfed

async-exit-stack

AsyncExitStack backport for Python 3.5+

async-exit-stack v1.0.1 88.0K downloads/30d#13,754 on PyPI8
Permissive license Python Software Foundation License Abandoned released

What it is and what it does

AsyncExitStack is a backport of Python 3.7's asynchronous context manager from the standard library, extracted into a standalone package for use on Python 3.5 and 3.6. It allows you to combine multiple async context managers and register async cleanup callbacks within a single async with block, ensuring resources are properly released even if exceptions occur during setup.

The package is essentially a copy of CPython's implementation and provides the same API as the standard library version: enter_async_context() to register async context managers, push_async_callback() to register coroutine cleanup handlers, and aclose() to trigger cleanup. It is most useful as a compatibility shim for older Python versions; modern projects targeting Python 3.7+ should use the built-in contextlib.AsyncExitStack instead.

Use it for:

  • Managing multiple database or network connections in async code on Python 3.5–3.6 with automatic cleanup.
  • Registering async cleanup handlers (e.g., closing resources) that must run even if earlier setup steps fail.
  • Combining both sync and async context managers in a single async with block on older Python versions.
  • Porting async code from Python 3.7+ back to Python 3.5–3.6 without rewriting resource management logic.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Provides AsyncExitStack, a backport of Python 3.7's asynchronous context manager for combining and cleaning up both sync and async context managers in async code.

No, unless you are maintaining legacy code on Python 3.5 or 3.6. The package is abandoned and receives no updates. Modern Python versions (3.7+) include AsyncExitStack in the standard library; use that instead. If you must support older Python, this backport works but carries no active maintenance risk mitigation.

Install

async-exit-stack on PyPI

pip

pip install async-exit-stack

uv

uv add async-exit-stack

poetry

poetry add async-exit-stack

Installing async-exit-stack

Before you install

Installation is straightforward with no runtime dependencies. However, the package is abandoned—last updated in 2022 with no commits since December 2022—so it receives no active maintenance or security updates.

License in practice

Licensed under the Python Software Foundation License (permissive), which allows free use, modification, and distribution with minimal restrictions.

Quickstart

pip install async-exit-stack

from async_exit_stack import AsyncExitStack

async def example():
    async with AsyncExitStack() as stack:
        resource = await stack.enter_async_context(get_connection())
        # Resource automatically cleaned up on exit

Requires Python 3.5 or later; intended for older Python versions that lack native AsyncExitStack support.

Verify before relying

  • Whether AsyncExitStack is still needed: Python 3.7+ includes it in the standard library contextlib module.
  • Compatibility with Python versions beyond 3.6: classifiers list only 3.5 and 3.6, but requires_python states >=3.5.

Package facts

License Python Software Foundation License (permissive)
Python support supports the current Python release (>=3.5)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance abandoned — 3,021 days since the last release
Last repo commit
First released
Downloads 88,016/month — #13,754 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: async_exit_stack-1.0.1-py3-none-any.whl

Keywords: async_exit_stack

Development Status :: 5 - Production/StableIntended Audience :: DevelopersLicense :: OSI Approved :: Python Software Foundation LicenseNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3.5Programming Language :: Python :: 3.6

Tags

async context manager cleanupasyncexitstack backportasync resource managementasync context manager compositionasync cleanup handlersasync with statement helpers
backportlegacy-pythonasync-utilities

More Software Development packages