Metadata-Version: 2.1
Name: async-batcher
Version: 0.2.1
Summary: A service to batch your http requests.
Home-page: https://github.com/hussein-awala/async-batcher
License: Apache-2.0
Keywords: python,asyncio,rest,grpc,fastapi
Author: Hussein Awala
Author-email: hussein@awala.fr
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: aws
Provides-Extra: keras
Provides-Extra: scylla
Provides-Extra: sklearn
Provides-Extra: sqlalchemy
Requires-Dist: aioboto3 (>=13.1,<14.0) ; extra == "aws"
Requires-Dist: keras (>=2.12,<3.0) ; (python_version < "3.12") and (extra == "keras")
Requires-Dist: keras (>=2.12,<4) ; (python_version == "3.12") and (extra == "keras")
Requires-Dist: scikit-learn (>=1.2,<2.0) ; (python_version < "3.12") and (extra == "sklearn")
Requires-Dist: scikit-learn (>=1.3,<2.0) ; (python_version == "3.12") and (extra == "sklearn")
Requires-Dist: scylla-driver (>=3,<4) ; extra == "scylla"
Requires-Dist: sqlalchemy[asyncio] (>=1.4,<3) ; extra == "sqlalchemy"
Project-URL: Bug Tracker, https://github.com/hussein-awala/async-batcher/issues
Project-URL: Documentation, https://github.com/hussein-awala/async-batcher/blob/main/README.md
Project-URL: Repository, https://github.com/hussein-awala/async-batcher
Description-Content-Type: text/markdown

# Async Batcher

This project provides a Python library to batch the asynchronous requests and handle them in batches.

## How to use

To use the library, you need to install the package in your environment. You can install the package using pip:

```bash
pip install async-batcher
```

Then, you can create a new `AsyncBatcher` class by implementing the `process_batch` method:

```python
from async_batcher.batcher import AsyncBatcher

class MyAsyncBatcher(AsyncBatcher):
    async def process_batch(self, batch):
        # Process the batch
        print(batch)

# Create a new instance of the `MyAsyncBatcher` class
async_batcher = MyAsyncBatcher(max_batch_size=20)
async_batcher.start()
```

## Benchmark

The benchmark is available in the [BENCHMARK.md](https://github.com/hussein-awala/async-batcher/blob/main/BENCHMARK.md)
file.

## Use cases

The `AsyncBatcher` library can be used in any application that needs to handle asynchronous requests in batches,
such as:
- Serving machine learning models that optimize the batch processing (e.g. TensorFlow, PyTorch, Scikit-learn, etc.)
- Storing multiple records in a database in a single query to optimize the I/O operations (or to reduce the cost of the
  database operations, e.g. AWS DynamoDB)
- Sending multiple messages in a single request to optimize the network operations (or to reduce the cost of the network
  operations, e.g. Kafka, RabbitMQ, AWS SQS, AWS SNS, etc.)


