Skip to main content

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; None means 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

aioautobatch-0.1.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aioautobatch-0.1.1-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file aioautobatch-0.1.1.tar.gz.

File metadata

  • Download URL: aioautobatch-0.1.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aioautobatch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3cbe7152d97f8f0ebeb89a63ea58f8f69f47f99ee783e56d9de1f82b7c5fbc78
MD5 b9c9e909c42afb3511e465029ff3902b
BLAKE2b-256 2f04ebffbcebfd42b405803d8b61826b6b1af854fe6d6d3ef7037480c8f16724

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioautobatch-0.1.1.tar.gz:

Publisher: python-publish.yml on reyoung/aioautobatch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aioautobatch-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: aioautobatch-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for aioautobatch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e472e386d065207c482c4e54f598be4c0c4626f97e78869c9f70e1d53a622a8f
MD5 f6313a61ad0965406408117385f3b190
BLAKE2b-256 2b0f628cea25211876bd15795cf86e76f4e65464967dec8925fe3ca15c6910e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for aioautobatch-0.1.1-py3-none-any.whl:

Publisher: python-publish.yml on reyoung/aioautobatch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page