A simple and easy way to use asyncio & aiohttp libraries.
Project description
AIOEase
AIOEase simplifies asynchronous HTTP requests in Python, offering a straightforward interface for handling multiple requests asynchronously with rate limiting.
Proved a list of dictionaries and the requests_per_second_max (default 1). Returns the status, response, and request as a list of dictionaries.
Installation
pip install aioease
Usage
Execute multiple HTTP requests asynchronously with ease:
from aioease import execute_async_requests
requests = [
{"url": "https://httpbin.org/ip", "method": "get", "data": {"key": "value"}, "headers": {"header": "value"}},
{"url": "https://httpbin.org/ip", "method": "post", "data": {"key": "value"}, "headers": {"header": "value"}},
]
responses = execute_async_requests(requests, requests_per_second_max=10)
Returns:
responses = [
{
"status": 200,
"response": "{\n \"origin\": \"00.000.00.000\"\n}\n",
},
{
"status": 405,
"response": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>405 Method Not Allowed</title>\n<h1>Method Not Allowed</h1>\n<p>The method is not allowed for the requested URL.</p>\n",
}
]
Given a unique identifyer to match requests to the responses.
from aioease import execute_async_requests
requests = [
{"url": "https://httpbin.org/ip", "method": "get", "data": {"key": "value"}, "headers": {"header": "value"},"id": "unique-identifyer-1"},
{"url": "https://httpbin.org/ip", "method": "post", "data": {"key": "value"}, "headers": {"header": "value"},"id": "unique-identifyer-2"},
]
responses = execute_async_requests(requests, requests_per_second_max=10)
Returns:
responses = [
{
"status": 200,
"response": "{\n \"origin\": \"00.000.00.000\"\n}\n",
"id": "unique-identifyer-1"
},
{
"status": 405,
"response": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n<title>405 Method Not Allowed</title>\n<h1>Method Not Allowed</h1>\n<p>The method is not allowed for the requested URL.</p>\n",
"id": "unique-identifyer-2"
}
]
Configuring Logging
Control the verbosity of logs for debugging:
import logging
logging.basicConfig(level=logging.INFO)
logging.basicConfig(level=logging.DEBUG)
logging.basicConfig(level=logging.ERROR)
License
Available under the MIT License.
Support
For support, please open an issue on the GitHub issue tracker.
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 Distributions
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 aioease-0.1.26-py3-none-any.whl.
File metadata
- Download URL: aioease-0.1.26-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
453de639b420044be6f1fd84e62b59d0cee4cbbecadf627950f5ea9c9cc54c64
|
|
| MD5 |
ccd92803ceb77ee15b4b47cd7c1f34c6
|
|
| BLAKE2b-256 |
2242f0e28eb8f191130b249699382ffec665f9c37f62f79ca372c8f06ca41382
|