Skip to main content

AsyncExitStack backport for Python 3.5+

Project description

AsyncExitStack backport for Python 3.5+

This package contains code from the CPython project.


pip install async_exit_stack

Usage example

from async_exit_stack import AsyncExitStack

async def some_async_function():
    async with AsyncExitStack() as stack:
        connections = [await stack.enter_async_context(get_connection())
            for i in range(5)]
        # All opened connections will automatically be released at the end of
        # the async with statement, even if attempts to open a connection
        # later in the list raise an exception.


Refer to Python 3.7 contextlib documentation for a complete reference and more context.

class AsyncExitStack

An asynchronous context manager, similar to ExitStack, that supports combining both synchronous and asynchronous context managers, as well as having coroutines for cleanup logic.

The close() method is not implemented, aclose() must be used instead.

Similar to enter_context() but expects an asynchronous context manager.
Similar to push() but expects either an asynchronous context manager or a coroutine.
push_async_callback(callback, *args, **kwds)
Similar to callback() but expects a coroutine.
Similar to close() but properly handles awaitables.


1.0.0 (2018-05-07)

  • First release based on Python 3.7b4.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for async-exit-stack, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size async_exit_stack-1.0.1-py3-none-any.whl (4.7 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size async_exit_stack-1.0.1.tar.gz (10.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page