Like anyio task groups, but for contexts
Project description
anyio-contextgroup
anyio-contextgroup is a utiliity mechanism for establishing an
anchored async context. This allows ExitStack-like behavior while
maintaining structured concurrency. It works by running all context
operations within a parent, outermost TaskGroup.
Getting started
Available as anyio-contextgroup on pypi.
At a glance
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
from anyio_contextgroup import create_context_group
@asynccontextmanager
async def my_ctx(val: str) -> AsyncGenerator[int, None]:
try:
yield len(val)
finally:
print(f'{val=}')
async def main():
async with create_context_group() as ctx_group:
# Do some stuff
...
for _ in range(5):
ctx_retval = await ctx_group.enter_async_context(my_ctx, 'foo')
assert ctx_retval == 3 # len('foo')
# Do some other stuff
...
# Now the context group will close, calling ``print()`` from ``my_ctx``
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file anyio_contextgroup-2026.4.14.0.tar.gz.
File metadata
- Download URL: anyio_contextgroup-2026.4.14.0.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
471c6acaae4e928ae4ffce1a92ccffba14f914d2abd285227557b8d17c786dc9
|
|
| MD5 |
07c3d8fa688eb662ae083a7f1af3e816
|
|
| BLAKE2b-256 |
063f5f02a0895078330d4bb54eb43d0c7ed248346179482c9d25fe14b67c27bc
|
Provenance
The following attestation bundles were made for anyio_contextgroup-2026.4.14.0.tar.gz:
Publisher:
on_release-publish_pypi.yaml on taev-tech/anyio_contextgroup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyio_contextgroup-2026.4.14.0.tar.gz -
Subject digest:
471c6acaae4e928ae4ffce1a92ccffba14f914d2abd285227557b8d17c786dc9 - Sigstore transparency entry: 1297427696
- Sigstore integration time:
-
Permalink:
taev-tech/anyio_contextgroup@c35dcba672e4eb7532fa0587b433b50065d5c73b -
Branch / Tag:
refs/tags/2026.04.14.0 - Owner: https://github.com/taev-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_release-publish_pypi.yaml@c35dcba672e4eb7532fa0587b433b50065d5c73b -
Trigger Event:
release
-
Statement type:
File details
Details for the file anyio_contextgroup-2026.4.14.0-py3-none-any.whl.
File metadata
- Download URL: anyio_contextgroup-2026.4.14.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62bb86edc801277de1f4cf48dd9e10ee509ae551ebdc216e009921770164015e
|
|
| MD5 |
761c51eb72c6f1150024250b47da5687
|
|
| BLAKE2b-256 |
7ba36ad20c30b56b1d71902fea915f931443a4369c2207efa6f69520752bab9d
|
Provenance
The following attestation bundles were made for anyio_contextgroup-2026.4.14.0-py3-none-any.whl:
Publisher:
on_release-publish_pypi.yaml on taev-tech/anyio_contextgroup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
anyio_contextgroup-2026.4.14.0-py3-none-any.whl -
Subject digest:
62bb86edc801277de1f4cf48dd9e10ee509ae551ebdc216e009921770164015e - Sigstore transparency entry: 1297427774
- Sigstore integration time:
-
Permalink:
taev-tech/anyio_contextgroup@c35dcba672e4eb7532fa0587b433b50065d5c73b -
Branch / Tag:
refs/tags/2026.04.14.0 - Owner: https://github.com/taev-tech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
on_release-publish_pypi.yaml@c35dcba672e4eb7532fa0587b433b50065d5c73b -
Trigger Event:
release
-
Statement type: