AsyncExitStack backport for Python 3.5+
Free software: PSF license
Documentation: https://docs.python.org/3.7/library/contextlib.html#contextlib.AsyncExitStack
This package contains code from the CPython project.
Install
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.
Reference
Refer to Python 3.7 contextlib documentation for a complete reference and more context.
class AsyncExitStackAn 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.
enter_async_context(cm)Similar to enter_context() but expects an asynchronous context manager.
push_async_exit(exit)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.
aclose()Similar to close() but properly handles awaitables.
History
1.0.0 (2018-05-07)
First release based on Python 3.7b4.
Metadata
Release files for async-exit-stack 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| async_exit_stack-1.0.1.tar.gz | 10.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| async_exit_stack-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / async_exit_stack-1.0.1.tar.gz
| Download URL | async_exit_stack-1.0.1.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
24de1ad6d0ff27be97c89d6709fa49bf20db179eaf1f4d2e6e9b4409b80e747d
|
|
BLAKE2b-256 checksum How to use checksums |
339cecf37497cd8c4aa6d62de0a67deeb80d4407fd930a689362e588458aff81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / async_exit_stack-1.0.1-py3-none-any.whl
| Download URL | async_exit_stack-1.0.1-py3-none-any.whl |
|---|---|
| Size | 4.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9b43b17683b3438f428ef3bbec20689f5abbb052aa4b564c643397330adfaa99
|
|
BLAKE2b-256 checksum How to use checksums |
77aef5baabf02fe19c4015b0417e72e36220fb95ed3e7cf17e8a85004b964709
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |