Add your description here
Project description
aioautobatch
Lightweight asyncio helper that batches many small calls into fewer async batch calls. It wraps your batch function and returns an awaitable that resolves with the corresponding result.
Install
pip install .
Python 3.11+ is required; the project targets Python 3.14 in pyproject.toml.
Usage
import asyncio
from aioautobatch import autobatch
async def batch_add(args_list: list[tuple[int, int]]) -> list[int]:
# Called once per batch with all pending arguments.
return [a + b for a, b in args_list]
async def main():
add = autobatch(batch_add, start_delay=0.05, batch_size=5)
# Each call returns a future tied to its position in the batch.
futures = [await add(i, i + 1) for i in range(8)]
results = await asyncio.gather(*futures)
print(results) # [1, 3, 5, 7, 9, 11, 13, 15]
asyncio.run(main())
Key parameters
start_delay: initial window (seconds) to collect the first batch.batch_size: maximum items per batch;Nonemeans unbounded.max_delay: max wait between batches after the first batch starts.max_concurrent_batches: cap concurrent in-flight batches.on_exception: optional callback invoked when a batch raises.
Tests
python3 -m unittest discover -s tests
Unit tests cover batching behavior, batch sizing, concurrency limits, and exception propagation.
Project details
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 aioautobatch-0.1.4.tar.gz.
File metadata
- Download URL: aioautobatch-0.1.4.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
04859c5d7a4add60a77a3c6f2eb9904409465eccfd993e16dbb81fbbb4fcc152
|
|
| MD5 |
02e73ee24a9834ecfb54c67f48877efb
|
|
| BLAKE2b-256 |
6ad1498297aaca7202febac2916eddf4e3b90a3bbdef6f92dbe8b7b9934c61a9
|
Provenance
The following attestation bundles were made for aioautobatch-0.1.4.tar.gz:
Publisher:
python-publish.yml on reyoung/aioautobatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioautobatch-0.1.4.tar.gz -
Subject digest:
04859c5d7a4add60a77a3c6f2eb9904409465eccfd993e16dbb81fbbb4fcc152 - Sigstore transparency entry: 871736649
- Sigstore integration time:
-
Permalink:
reyoung/aioautobatch@3ca7462343b8b2afb1a43f568cc0ad414c1b85d1 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/reyoung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3ca7462343b8b2afb1a43f568cc0ad414c1b85d1 -
Trigger Event:
release
-
Statement type:
File details
Details for the file aioautobatch-0.1.4-py3-none-any.whl.
File metadata
- Download URL: aioautobatch-0.1.4-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7922ed8a1308967010162728f7008b54332d9c7aefc673da5d6c14b7cba98446
|
|
| MD5 |
a1dc62d33291798e3e4b25b49a6962a6
|
|
| BLAKE2b-256 |
d3212def84624aa018ca1f735edca7d7c6baac8816e21774bac83d0ae7ea25f1
|
Provenance
The following attestation bundles were made for aioautobatch-0.1.4-py3-none-any.whl:
Publisher:
python-publish.yml on reyoung/aioautobatch
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aioautobatch-0.1.4-py3-none-any.whl -
Subject digest:
7922ed8a1308967010162728f7008b54332d9c7aefc673da5d6c14b7cba98446 - Sigstore transparency entry: 871736653
- Sigstore integration time:
-
Permalink:
reyoung/aioautobatch@3ca7462343b8b2afb1a43f568cc0ad414c1b85d1 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/reyoung
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@3ca7462343b8b2afb1a43f568cc0ad414c1b85d1 -
Trigger Event:
release
-
Statement type: