Add your description here
Project description
Aio Adaptive
The goal is to enable an http adaptive rate limit library for python. Project is based off of Netflix Concurrency, but for python! This library is currently only useful in asyncio setup. The initial setup allows for someone to configure the Vegas adaptive rate limit.
The library will automatically limit the outbound requests wrapped in client.use() context manager.
Within that manager it utilizes an async semaphore to limit the amount of concurrent calls for this client.
See the examples below for how to leverage it.
Install
You can install aioadaptive using pip:
pip install aioadaptive
Or, if you use uv:
uv add aioadaptive
How to Use
Client Setup
from aioadaptive import AdaptiveClient, AdaptiveClientConfig
# Default configuration is to use `vegas` algorithm
client = AdaptiveClient()
# Same as doing
client = AdaptiveClient(AdaptiveClientConfig(algorithm="vegas"))
# Which is also the same as doing
client = AdaptiveClient(AdaptiveClientConfig(algorithm="vegas"))
async def main():
async with client.use():
# Do something with adaptive rate limiting client
pass
asyncio.run(main())
With aiohttp (async)
import aiohttp
from aioadaptive import AdaptiveClient
import asyncio
client = AdaptiveClient()
async def main():
async with aiohttp.ClientSession() as session:
async with client.use():
async with session.get("https://example.com/") as resp:
data = await resp.json()
print(data)
asyncio.run(main())
With httpx (async)
import httpx
from aioadaptive import AdaptiveClient
import asyncio
client = AdaptiveClient()
async def main():
async with httpx.AsyncClient() as session:
async with client.use():
resp = await session.get("https://example.com/")
print(resp.json())
asyncio.run(main())
With requests (sync, not recommended for adaptive concurrency)
Note:
requestsis synchronous and blocking, so you won't get the full benefit of adaptive concurrency and is therefore not supported
Developer Setup
-
Navigate to the Server Directory
cd aioadaptive
-
Install Server Requirements
uv venv .venv source .venv/bin/activate uv sync
Development Testing
To run the full test suite (includes integration tests which can be slower)
pytest
Exclude integration tests
pytest -m "not integration"
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 aioadaptive-0.1.4.tar.gz.
File metadata
- Download URL: aioadaptive-0.1.4.tar.gz
- Upload date:
- Size: 70.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ebb67d9f9fcc9a4ffa6729f53d3520cadbd9040e33bb0e919462883abef9d70
|
|
| MD5 |
388f68b7acd8f1cd1ed8616a69e66bf8
|
|
| BLAKE2b-256 |
bc6c4473187770fb6ff8daf02366a35239beed8ac59fa2d02d5864cca069402b
|
File details
Details for the file aioadaptive-0.1.4-py3-none-any.whl.
File metadata
- Download URL: aioadaptive-0.1.4-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.8.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3b8ac2c63f216b55f4c886861dbbffc92906e86c748462930f6cfb5b9b53b60
|
|
| MD5 |
10bf86dc40f70e828260a6f37d5556b9
|
|
| BLAKE2b-256 |
1f0f4d76ba97554b01200f57d6317dd0368218c230bd8ed39e6e722b59e58e7e
|